Use slim container variant

This reduces the size of the container, which makes working with it much easier
This commit is contained in:
Jake Howard 2022-08-27 18:22:58 +01:00
parent 54a7dd2660
commit c6776faa8c
Signed by: jake
GPG Key ID: 57AFB45680EDD477
2 changed files with 17 additions and 6 deletions

View File

@ -21,7 +21,7 @@ static:
expire_in: 30 mins
pip:
image: python:3.10
image: python:3.10-slim
stage: build
variables:
PIP_CACHE_DIR: $CI_PROJECT_DIR/.pip-cache
@ -29,6 +29,9 @@ pip:
key: pip-$CI_COMMIT_REF_SLUG
paths:
- "$CI_PROJECT_DIR/.pip-cache"
before_script:
- apt-get update --yes
- apt-get install --yes build-essential libpq-dev
script:
- python -m venv env
- source env/bin/activate
@ -40,11 +43,12 @@ pip:
expire_in: 30 mins
.python_test_template:
image: python:3.10
image: python:3.10-slim
stage: test
dependencies:
- pip
before_script:
- apt-get update && apt-get install --yes git libpq-dev
- source env/bin/activate
variables:
SECRET_KEY: super-secret
@ -144,7 +148,7 @@ container:
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker build -t website --target production -t $DEV_IMAGE_TAG .
- docker build --target production -t $DEV_IMAGE_TAG .
- docker push $DEV_IMAGE_TAG
- >
if [ "$CI_COMMIT_REF_SLUG" == "master"]; then

View File

@ -1,7 +1,7 @@
FROM node:16-slim as frontend
COPY package.json package-lock.json ./
RUN npm ci --no-audit --progress=false --omit=dev
RUN npm ci --no-audit - -progress=false --omit=dev
# Compile static files
COPY ./scripts ./scripts
@ -9,7 +9,7 @@ COPY ./static/src ./static/src
RUN npm run build
# The actual container
FROM python:3.10 as production
FROM python:3.10-slim as production
ENV VIRTUAL_ENV=/venv
@ -17,7 +17,12 @@ RUN useradd website --create-home -u 1000 && mkdir /app $VIRTUAL_ENV && chown -R
WORKDIR /app
RUN wget https://github.com/aptible/supercronic/releases/download/v0.2.1/supercronic-linux-amd64 -O /usr/local/bin/supercronic && chmod +x /usr/local/bin/supercronic
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
build-essential \
libpq-dev \
curl
RUN curl -fsSL https://github.com/aptible/supercronic/releases/download/v0.2.1/supercronic-linux-amd64 -o /usr/local/bin/supercronic && chmod +x /usr/local/bin/supercronic
ENV PATH=$VIRTUAL_ENV/bin:$PATH \
PYTHONUNBUFFERED=1
@ -30,6 +35,8 @@ RUN python -m venv $VIRTUAL_ENV
COPY --chown=website requirements/base.txt ./requirements/base.txt
RUN pip install --no-cache --upgrade pip && pip install --no-cache -r ./requirements/base.txt
RUN apt-get remove --yes build-essential && apt-get autoremove --yes && rm -rf /var/lib/apt/lists /var/cache/apt
COPY --chown=website --from=frontend ./static/build ./static/build
COPY --chown=website ./etc ./etc