Skip to content

Instantly share code, notes, and snippets.

Created April 12, 2019 13:10
What would you like to do?
GitLab CI configuration to lint and build Docker images and push them to AWS ECR
- Lint images
- Build and publish images
## Load a node.js image, install dockerlint and lint all Dockerfiles
stage: Lint images
image: node:4-alpine
- npm install -g dockerlint && npm cache clean
- find ./ -name Dockerfile -exec dockerlint {} \;
## Load a docker image and install AWS CLI and
## use docker:dind as a service to build all images
## and push them to the registry
stage: Build and publish images
image: docker:latest
- docker:dind
- master
- export DEBIAN_FRONTEND=noninteractive
# Install nodejs and python
- apk update -qy && apk add -y --no-cache nodejs curl unzip bash
- apk add --no-cache python3 && python3 -m ensurepip && rm -r /usr/lib/python*/ensurepip && pip3 install --upgrade pip setuptools && if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && rm -r /root/.cache
# Install AWS CLI
- curl "" -o ""
- unzip
- ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
# Login to AWS ECR
- $(aws ecr get-login --no-include-email --region ${AWS_REGION})
# Build all images over here. This is only a placeholder for
# e.g. your magic script to build all images in your repo.
- docker build ...
- docker tag ...
- docker push ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment