From 15b0ba27cfb8ce7c29711d809d58f56ea4be99ba Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 13 Jun 2018 13:19:49 +0100 Subject: Push site base image on CI. --- docker/Dockerfile.base | 25 ------------------------- docker/base.Dockerfile | 17 +++++++++++++++++ docker/ci.Dockerfile | 23 ----------------------- 3 files changed, 17 insertions(+), 48 deletions(-) delete mode 100644 docker/Dockerfile.base create mode 100644 docker/base.Dockerfile delete mode 100644 docker/ci.Dockerfile (limited to 'docker') diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base deleted file mode 100644 index 7119d770..00000000 --- a/docker/Dockerfile.base +++ /dev/null @@ -1,25 +0,0 @@ -FROM python:3.6-alpine3.7 - -RUN apk add --update tini -RUN apk add --update git -RUN apk add --update build-base -RUN apk add --update gcc -RUN apk add --update cmake -RUN apk add --update autoconf -RUN apk add --update automake -RUN apk add --update libtool - -ENV PIPENV_VENV_IN_PROJECT=1 -ENV PIPENV_IGNORE_VIRTUALENVS=1 -ENV PIPENV_NOSPIN=1 -ENV PIPENV_HIDE_EMOJIS=1 - -RUN pip install pipenv - -RUN mkdir -p /site -COPY Pipfile /site -COPY Pipfile.lock /site -WORKDIR /site -ENV PYTHONPATH=/site - -RUN pipenv sync diff --git a/docker/base.Dockerfile b/docker/base.Dockerfile new file mode 100644 index 00000000..7252598d --- /dev/null +++ b/docker/base.Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.7-alpine + +RUN apk add python3-dev git libpq postgresql-dev gcc cmake autoconf automake musl-dev +RUN python3 -m pip install pipenv + +ENV PIPENV_HIDE_EMOJIS=1 +ENV PIPENV_IGNORE_VIRTUALENVS=1 +ENV PIPENV_MAX_SUBPROCESS=2 +ENV PIPENV_NOSPIN=1 +ENV PIPENV_VENV_IN_PROJECT=1 + +COPY . /app +WORKDIR /app + +RUN pipenv install --deploy --system + +CMD ["gunicorn", "--workers", "4", "--bind", "0.0.0.0:4000", "pysite:wsgi"] diff --git a/docker/ci.Dockerfile b/docker/ci.Dockerfile deleted file mode 100644 index 0153696a..00000000 --- a/docker/ci.Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM python:3.6-alpine3.7 - -# Install base packages -RUN apk add --update autoconf automake \ - build-base \ - cmake curl \ - docker \ - gcc git \ - libtool \ - nodejs nodejs-npm \ - ruby ruby-dev ruby-irb ruby-rdoc \ - tini - -# Set up env vars -ENV PIPENV_VENV_IN_PROJECT=1 -ENV PIPENV_IGNORE_VIRTUALENVS=1 -ENV PIPENV_NOSPIN=1 -ENV PIPENV_HIDE_EMOJIS=1 - -# Install toolchain -RUN pip install pipenv -RUN gem install scss_lint -RUN npm install -g eslint gulp-cli -- cgit v1.2.3 From 5489bc670b936ee7732154e62688f085adfd5af8 Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Thu, 30 Aug 2018 19:35:24 +0200 Subject: Add CI build script. --- .gitlab-ci.yml | 13 ++++++++----- docker/base.Dockerfile | 1 + scripts/deploy-ci.sh | 24 ++++++++++-------------- 3 files changed, 19 insertions(+), 19 deletions(-) mode change 100644 => 100755 scripts/deploy-ci.sh (limited to 'docker') diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e026ce6..fe86b32c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,13 @@ -build: - image: docker - tags: docker +build base image: + image: docker:stable-git + script: + - sh scripts/deploy-ci.sh + tags: + - docker only: - master - script: - - scripts/deploy-ci.sh + - django + - django+add-gitlab-ci lint: image: pythondiscord/django-site-ci:latest diff --git a/docker/base.Dockerfile b/docker/base.Dockerfile index 7252598d..c90ee5dc 100644 --- a/docker/base.Dockerfile +++ b/docker/base.Dockerfile @@ -1,3 +1,4 @@ +# Base image used for building the site. FROM python:3.7-alpine RUN apk add python3-dev git libpq postgresql-dev gcc cmake autoconf automake musl-dev diff --git a/scripts/deploy-ci.sh b/scripts/deploy-ci.sh old mode 100644 new mode 100755 index 1bf8ce00..f5c965ca --- a/scripts/deploy-ci.sh +++ b/scripts/deploy-ci.sh @@ -1,23 +1,19 @@ #!/bin/bash # Build and deploy on master branch -if [[ $CI_COMMIT_REF_SLUG == 'master' ]]; then - echo "Connecting to docker hub" - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin +echo "Connecting to docker hub" +echo "$GITLAB_DOCKER_PASSWORD" | docker login --username "$GITLAB_DOCKER_USERNAME" --password-stdin registry.gitlab.com - changed_lines=$(git diff HEAD~1 HEAD docker/base.Dockerfile | wc -l) +changed_lines=$(git diff HEAD~1 HEAD docker/base.Dockerfile | wc -l) - if [ $changed_lines != '0' ]; then - echo "base.Dockerfile was changed" +if [ $changed_lines != '0' ]; then + echo "base.Dockerfile was changed" - echo "Building CI container" - docker build -t pythondiscord/django-site-ci:latest -f docker/base.Dockerfile . + echo "Building CI container" + docker build -t registry.gitlab.com/python-discord/projects/site/django-base:latest -f docker/base.Dockerfile . - echo "Pushing image to Docker Hub" - docker push pythondiscord/django-site-ci:latest - else - echo "base.Dockerfile was not changed, not building" - fi + echo "Pushing image to GitLab registry" + docker push registry.gitlab.com/python-discord/projects/site/django-base:latest else - echo "Skipping CI Docker build" + echo "base.Dockerfile was not changed, not building" fi -- cgit v1.2.3