Skip to content
Snippets Groups Projects
Verified Commit 0e198682 authored by Jan Maximilian Michal's avatar Jan Maximilian Michal
Browse files

Updated Dockerfile to support caching

parent dc2f0e0e
No related branches found
No related tags found
1 merge request!105Updated Dockerfile to support caching
Pipeline #
# Common
*/.git
.git
Dockerfile
# Django
......@@ -9,7 +9,8 @@ Dockerfile
*.pyo
*.pyd
*/env*
*/.venv*
.venv
.ipynb_checkpoints
pip-log.txt
pip-delete-this-directory.txt
.tox
......@@ -26,3 +27,4 @@ public/
# node
*/node_modules
*/npm-debug.log
*/dist
stages:
- build
- test
- pages
- build_image
- pages
- staging
variables:
......@@ -74,6 +74,16 @@ test_frontend:
paths:
- frontend/node_modules/
# =========================== Build Image section ============================ #
build_backend:
image: docker:latest
stage: build_image
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $IMAGE_TAG .
- docker tag $IMAGE_TAG $IMAGE_TAG-$CI_COMMIT_SHA
- docker push $IMAGE_TAG
# =========================== Gitlab pages section =========================== #
pages:
<<: *test_definition_virtualenv
......@@ -90,18 +100,6 @@ pages:
only:
- master
# =========================== Build Image section ============================ #
build_backend:
image: docker:latest
stage: build_image
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $IMAGE_TAG .
- docker tag $IMAGE_TAG $IMAGE_TAG-$CI_COMMIT_SHA
- docker push $IMAGE_TAG
only:
- master
# ============================== Staging section ============================= #
.staging_template: &staging_definition
stage: staging
......
# Build Vue files
FROM node:carbon as node
WORKDIR /app/
COPY frontend/ .
COPY frontend/package.json .
COPY frontend/yarn.lock .
RUN yarn
RUN npm install
RUN npm run build
# CACHED
COPY frontend/ .
RUN yarn build
# Now fetch other files and build on small image
FROM python:3.6-alpine
ENV PYTHONUNBUFFERED 1
WORKDIR /code
# This set is need otherwise the postgres driver wont work
# This set is needed otherwise the postgres driver wont work
RUN apk update \
&& apk add --virtual build-deps gcc python3-dev musl-dev curl \
&& apk add --no-cache postgresql-dev
WORKDIR /code
COPY requirements.txt .
RUN pip install -r requirements.txt && rm -rf /root/.cache
COPY . /code
# CACHED
COPY . .
COPY --from=node /app/dist /code/frontend/dist
COPY --from=node /app/dist/index.html /code/core/templates/index.html
RUN pip install -r requirements.txt && rm -rf /root/.cache
ENV PYTHONUNBUFFERED 1
RUN python util/format_index.py
RUN python manage.py collectstatic --noinput
RUN apk del build-deps
CMD ["./deploy.sh"]
......@@ -12,8 +12,9 @@ services:
grady:
image: docker.gitlab.gwdg.de/j.michal/grady:master
command:
- ./deploy.sh
command: >
bash -c "./manage.py maketestdata &&
./deploy.sh"
depends_on:
- postgres
restart: always
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment