Skip to content

Commit 2cb0e5f

Browse files
committed
hotfix: update docker files and workflow
- Drop python image version to 3.9.* due to dependency python support limitation: see ets-labs/python-dependency-injector#765
1 parent 92a4a47 commit 2cb0e5f

File tree

5 files changed

+20
-31
lines changed

5 files changed

+20
-31
lines changed

.dockerignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@
22
.git
33
.github
44
.gitignore
5+
renovate.json
6+
README.md
57

68
# Django
79
*.log
810
*.pot
911
*.pyc
1012
*.sqlite3
1113
*.sqlite3-journal
12-
__pycache__/
13-
migrations/
1414

15-
# General Directories
15+
# General directories
1616
.idea
1717
.graphql
1818
media-content
1919
fixtures
2020
docs
2121
tmp
22+
__pycache__
23+
migrations
2224

2325
# General files
2426
*.md
2527
.env
2628
.env.defaults
27-
renovate.json
2829
pytest.ini
2930

3031
# Docker files

.github/workflows/django-cd.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ jobs:
3232
- name: Set Tag
3333
id: set-tag
3434
run: |
35-
if [[ -z "${{ github.event.inputs.tag }}" && -z "${GITHUB_REF#refs/tags/}" ]]; then
35+
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
3636
echo "::set-output name=tag::latest"
37+
elif [[ -z "${{ github.event.inputs.tag }}" && -n "${GITHUB_REF#refs/tags/}" ]]; then
38+
echo "::set-output name=tag::latest"
39+
elif [[ -n "${{ github.event.inputs.tag }}" ]]; then
40+
echo "::set-output name=tag::${{ github.event.inputs.tag }}"
3741
else
38-
if [ -z "${{ github.event.inputs.tag }}" ]; then
39-
echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
40-
else
41-
echo "::set-output name=tag::${{ github.event.inputs.tag }}"
42-
fi
42+
echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
4343
fi
44-
4544
- name: Build and Push Docker Image
4645
run: |
4746
docker buildx create --use

Dockerfile

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
1-
# Stage 1: Build stage
2-
FROM python:3.12.3-slim AS builder
3-
4-
# Set the working directory in the container
1+
FROM python:3.11.9-slim AS base
52
WORKDIR /usr/src
3+
COPY . /usr/src/
64

7-
# Install system dependencies and upgrade pip
5+
FROM base AS scaffold
86
RUN apt-get update \
97
&& apt-get install -y --no-install-recommends \
108
build-essential \
119
libpq-dev \
1210
&& rm -rf /var/lib/apt/lists/* \
1311
&& pip install --upgrade pip
1412

15-
# Copy only the dependency files to leverage caching
16-
COPY pyproject.toml poetry.lock /usr/src/
17-
18-
# Install project dependencies
13+
FROM scaffold AS dependencies
1914
RUN pip install poetry==1.5.0 \
2015
&& poetry config virtualenvs.create false \
2116
&& poetry install --no-interaction --no-ansi
2217

23-
# Copy the rest of the project code
24-
COPY . /usr/src/
25-
26-
# Stage 2: Final image
27-
FROM builder AS final
28-
29-
# Define your environment variables
18+
FROM dependencies AS final
3019
ENV PYTHONDONTWRITEBYTECODE 1
3120
ENV PYTHONUNBUFFERED 1

docker-compose.dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ services:
1010
- default
1111
env_file: .env
1212
labels:
13-
- "traefik.enable=true"
13+
- "traefik.enable=${TRAEFIK_ENABLE}"
1414
- "traefik.http.routers.anitrend.rule=Host(`${HOST}`)"
1515
- "traefik.http.routers.anitrend.entrypoints=web,websecure"
1616
- "traefik.http.routers.anitrend.service=anitrend"
1717
- "traefik.http.routers.anitrend.tls=true"
18-
- "traefik.http.routers.anitrend.tls.certresolver=staging"
18+
- "traefik.http.routers.anitrend.tls.certresolver=${CERT_RESOLVER}"
1919
- "traefik.http.services.anitrend.loadbalancer.server.port=${PORT}"
2020
logging:
2121
options:

docker-compose.prod.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ services:
88
- default
99
env_file: .env
1010
labels:
11-
- "traefik.enable=true"
11+
- "traefik.enable=${TRAEFIK_ENABLE}"
1212
- "traefik.http.routers.anitrend.rule=Host(`${HOST}`)"
1313
- "traefik.http.routers.anitrend.entrypoints=web,websecure"
1414
- "traefik.http.routers.anitrend.service=anitrend"
1515
- "traefik.http.routers.anitrend.tls=true"
16-
- "traefik.http.routers.anitrend.tls.certresolver=production"
16+
- "traefik.http.routers.anitrend.tls.certresolver=${CERT_RESOLVER}"
1717
- "traefik.http.services.anitrend.loadbalancer.server.port=${PORT}"
1818
logging:
1919
options:

0 commit comments

Comments
 (0)