Skip to content

Instantly share code, notes, and snippets.

@dbathily
Created July 23, 2013 22:24
Show Gist options
  • Save dbathily/6066712 to your computer and use it in GitHub Desktop.
Save dbathily/6066712 to your computer and use it in GitHub Desktop.
Upload play framework 2 build to amazon s3
import sbt._
import Keys._
import play.Project._
import com.typesafe.sbt.S3Plugin._
import S3._
object ApplicationBuild extends Build {
val appName = "sample"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
jdbc,
anorm
)
val main = play.Project(appName, appVersion, appDependencies).settings(s3Settings: _*).settings(
//Show the progress
S3.progress in S3.upload := true,
mappings in upload <<= dist map { distFile =>
Seq(distFile -> distFile.name)
//You can choose different name
//Seq(distFile -> "snapshot/%s/%s/%s-%s.zip".format(appName, appVersion, appName, appVersion))
},
//The bucket url
host in upload := "BUCKET_NAME.s3.amazonaws.com",
//The bucket credential
credentials += Credentials("Amazon S3", "BUCKET_NAME.s3.amazonaws.com", "Access Key Id", "Secret Access Key")
//Or credentials in a file
//credentials += Credentials(Path.userHome / ".s3credentials")
//.s3credentials
/*
realm=Amazon S3
host=BUCKET_NAME.s3.amazonaws.com
user=<Access Key ID>
password=<Secret Access Key>
*/
)
}
// Comment to get more information during initialization
logLevel := Level.Warn
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.2")
//https://github.com/sbt/sbt-s3
addSbtPlugin("com.typesafe.sbt" % "sbt-s3" % "0.5")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment