Posted at

PlayFrameworkをElastic Beanstalkのt2.microのdockerにdeployする

More than 3 years have passed since last update.

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.0-M1")

Native memory allocation (malloc) failed to allocate 715849728 bytes for committing reserved memory.

build.sbtに下記を追記する。

def creteEbextensions: Unit = {

val directory = new File("target/docker/.ebextensions")
val file = new File("target/docker/.ebextensions/env.config")
val contents =
"""commands:
| 01_enable_sudo:
| command: "echo Defaults:root !requiretty >> /etc/sudoers"
| test: "test ! -e /home/ec2-user/swapdone"
| 02_dd:
| command: "sudo dd if=/dev/zero of=/swapfile bs=1M count=1024"
| test: "test ! -e /home/ec2-user/swapdone"
| 03_mkswap:
| command: "sudo mkswap /swapfile"
| test: "test ! -e /home/ec2-user/swapdone"
| 04_swapon:
| command: "sudo swapon /swapfile"
| test: "test ! -e /home/ec2-user/swapdone"
| 05_swapdone:
| command: "touch /home/ec2-user/swapdone"
| test: "test ! -e /home/ec2-user/swapdone"
""".stripMargin
IO.createDirectory(directory)
IO.write(file, contents)
}

(stage in Docker) <<= stage in Docker andFinally creteEbextensions