Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GitLab CI configuration to lint and build Docker images and push them to AWS ECR
stages:
- Lint images
- Build and publish images
## Load a node.js image, install dockerlint and lint all Dockerfiles
linting:
stage: Lint images
image: node:4-alpine
script:
- 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
publishing:
stage: Build and publish images
image: docker:latest
services:
- docker:dind
only:
- master
script:
- 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 "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
- unzip awscli-bundle.zip
- ./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