diff options
Diffstat (limited to '')
| -rw-r--r-- | .gitlab-ci.yml | 26 | ||||
| -rw-r--r-- | Dockerfile | 18 | ||||
| -rw-r--r-- | docker/base.Dockerfile | 18 | 
3 files changed, 37 insertions, 25 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c6eaac3d..e9b56759 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,9 @@ stages:      - lint      - test      - deploy +    - cleanup +services: +    - registry  cache:      paths: @@ -11,11 +14,11 @@ cache:  variables:      PIPENV_CACHE_DIR: "$CI_PROJECT_DIR/.cache" -build base image: +build docker image:      image: docker:stable-git      stage: build      script: -        - sh scripts/deploy-ci.sh +        - docker build -t registry:5000/django-ci .      tags:          - docker      only: @@ -23,20 +26,20 @@ build base image:          - django  lint: -    image: registry.gitlab.com/python-discord/projects/site/django-base:latest +    image: registry:5000/django-ci      stage: lint      script:          - pipenv install --dev --system          - flake8  test: -    image: registry.gitlab.com/python-discord/projects/site/django-base:latest +    image: registry:5000/django-ci      stage: test      services:          - postgres:10-alpine      before_script: +        - pipenv install --dev --system          - python manage.py migrate -        - pip install coverage      script:          - coverage run --source=api,home,pysite,wiki --branch manage.py test      after_script: @@ -52,7 +55,6 @@ test:  pages:      stage: deploy -    image:       dependencies:          - test      before_script: @@ -63,3 +65,15 @@ pages:          paths:              - public          expire_in: 30 days + +upload newest docker image: +    image: docker:stable-git +    stage: deploy +    script: +        - echo "$GITLAB_DOCKER_PASSWORD" | docker login --username "$GITLAB_DOCKER_USERNAME" --password-stdin registry.gitlab.com +        - docker pull registry:5000/django-ci +        - docker image tag registry.gitlab.com/python-discord/projects/site/django:latest registry:5000/django-ci +        - docker push registry.gitlab.com/python-discord/projects/site/django:latest +    only: +        - master +        - django @@ -1 +1,17 @@ -FROM registry.gitlab.com/python-discord/projects/site/django-base:latest +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/base.Dockerfile b/docker/base.Dockerfile deleted file mode 100644 index c90ee5dc..00000000 --- a/docker/base.Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -# 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 -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"]  |