Skip to content

Instantly share code, notes, and snippets.

@iamvips
Forked from anka/.gitlab-ci.yml
Last active March 22, 2020 11:21
Show Gist options
  • Save iamvips/ed1f3f28b29b8ee30111292601d435bb to your computer and use it in GitHub Desktop.
Save iamvips/ed1f3f28b29b8ee30111292601d435bb to your computer and use it in GitHub Desktop.

Revisions

  1. @anka anka created this gist Apr 12, 2019.
    42 changes: 42 additions & 0 deletions .gitlab-ci.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    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 ...