Created
December 13, 2020 12:44
-
-
Save anshajk/ac87bc51ea19fc8af87c7f5986feeb04 to your computer and use it in GitHub Desktop.
Example buildspec.yml file and dockerfile for building docker image with AWS CloudBuild
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 0.2 | |
#env: | |
#variables: | |
# key: "value" | |
# key: "value" | |
#parameter-store: | |
# key: "value" | |
# key: "value" | |
phases: | |
install: | |
runtime-versions: | |
docker: 18 | |
commands: | |
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2& | |
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done" | |
pre_build: | |
commands: | |
- echo Logging in to Amazon ECR.... | |
- aws --version | |
# update the following line with your own region | |
- $(aws ecr get-login --no-include-email --region eu-central-1) | |
build: | |
commands: | |
- echo Build started on `date` | |
- echo Building the Docker image... | |
# update the following line with the name of your own ECR repository | |
- docker build -t mydockerrepo . | |
# update the following line with the URI of your own ECR repository (view the Push Commands in the console) | |
- docker tag mydockerrepo:latest 757250003982.dkr.ecr.eu-central-1.amazonaws.com/mydockerrepo:latest | |
post_build: | |
commands: | |
- echo Build completed on `date` | |
- echo pushing to repo | |
# update the following line with the URI of your own ECR repository | |
- docker push 757250003982.dkr.ecr.eu-central-1.amazonaws.com/mydockerrepo:latest | |
#artifacts: | |
# - location | |
# - location | |
#discard-paths: yes | |
#base-directory: location | |
#cache: | |
#paths: | |
# - paths | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:12.04 | |
# Install dependencies | |
RUN apt-get update -y | |
RUN apt-get install -y apache2 | |
# Install apache and write hello world message | |
RUN echo "Hello Cloud Gurus!!!! This web page is running in a Docker container!" > /var/www/index.html | |
# Configure apache | |
RUN a2enmod rewrite | |
RUN chown -R www-data:www-data /var/www | |
ENV APACHE_RUN_USER www-data | |
ENV APACHE_RUN_GROUP www-data | |
ENV APACHE_LOG_DIR /var/log/apache2 | |
EXPOSE 80 | |
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment