|sudo: required #is required to use docker service in travis|
|language: php #can be any language, just php for example|
|- docker # required, but travis uses older version of docker :(|
|- echo "install nothing!" # put your normal pre-testing installs here|
|- echo "no tests!" # put your normal testing scripts here|
|- docker --version # document the version travis is using|
|- pip install --user awscli # install aws cli w/o sudo|
|- export PATH=$PATH:$HOME/.local/bin # put aws in the path|
|- eval $(aws ecr get-login --region us-east-1) #needs AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY envvars|
|- docker build -t my_example_app .|
|- docker tag my_example_app:latest [your_ecr_account].dkr.ecr.us-east-1.amazonaws.com/my_example_app:latest|
|- docker push [your_ecr_account].dkr.ecr.us-east-1.amazonaws.com/my_example_app:latest|
|# sadly, travis doesn't cache docker builds yet, so each build will take a while|
@nikhilo: you can use travis script deployment: https://docs.travis-ci.com/user/deployment/script/ (just put all the docker operations in that script and make it return non 0 in case of failure).
@BretFisher how do you export env variables? I tried with
but travis says:
@georgschlenkhoff I think you'll need to add them as global env vars, otherwise Travis will run the build once with AWS_SECRET_ACCESS_KEY and once with AWS_ACCESS_KEY_ID, which is not what you want. See https://docs.travis-ci.com/user/environment-variables/#Global-Variables
Thank you so much!
Just a tip, if someone is receiving the error
Also, I improved the script with env variables.
@matheusmessora your env setings is wrong, the correct is
@matheusmessora do you find tagging with the build number more valuable than the git commit hash or PR title?
For those interested here's the list of Travis-provided env vars possibly suitable for tagging images: