Skip to content

Commit 66e67c7

Browse files
committed
Docker story refactoring
1 parent 9b3d9fe commit 66e67c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2957
-501
lines changed

.docker-backup/Dockerfile

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
FROM python:3.13.5-slim-bookworm AS build-image
2+
3+
# Install system dependencies needed for downloading and extracting
4+
RUN apt-get update -y && \
5+
apt-get install -y --no-install-recommends wget xz-utils unzip && \
6+
rm -rf /var/lib/apt/lists/* && \
7+
apt-get purge --auto-remove && \
8+
apt-get clean
9+
10+
RUN wget -q https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
11+
12+
RUN mkdir -p ffmpeg-tmp && \
13+
tar -xf ffmpeg-release-amd64-static.tar.xz --strip-components 1 -C ffmpeg-tmp && \
14+
cp -v ffmpeg-tmp/ffmpeg ffmpeg-tmp/ffprobe ffmpeg-tmp/qt-faststart /usr/local/bin && \
15+
rm -rf ffmpeg-tmp ffmpeg-release-amd64-static.tar.xz
16+
17+
# Install Bento4 in the specified location
18+
RUN mkdir -p /home/mediacms.io/bento4 && \
19+
wget -q http://zebulon.bok.net/Bento4/binaries/Bento4-SDK-1-6-0-637.x86_64-unknown-linux.zip && \
20+
unzip Bento4-SDK-1-6-0-637.x86_64-unknown-linux.zip -d /home/mediacms.io/bento4 && \
21+
mv /home/mediacms.io/bento4/Bento4-SDK-1-6-0-637.x86_64-unknown-linux/* /home/mediacms.io/bento4/ && \
22+
rm -rf /home/mediacms.io/bento4/Bento4-SDK-1-6-0-637.x86_64-unknown-linux && \
23+
rm -rf /home/mediacms.io/bento4/docs && \
24+
rm Bento4-SDK-1-6-0-637.x86_64-unknown-linux.zip
25+
26+
############ BASE RUNTIME IMAGE ############
27+
FROM python:3.13.5-slim-bookworm AS base
28+
29+
SHELL ["/bin/bash", "-c"]
30+
31+
ENV PYTHONUNBUFFERED=1
32+
ENV PYTHONDONTWRITEBYTECODE=1
33+
ENV CELERY_APP='cms'
34+
ENV VIRTUAL_ENV=/home/mediacms.io
35+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
36+
37+
# Install system dependencies first
38+
RUN apt-get update -y && \
39+
apt-get -y upgrade && \
40+
apt-get install --no-install-recommends -y \
41+
supervisor \
42+
nginx \
43+
imagemagick \
44+
procps \
45+
build-essential \
46+
pkg-config \
47+
zlib1g-dev \
48+
zlib1g \
49+
libxml2-dev \
50+
libxmlsec1-dev \
51+
libxmlsec1-openssl \
52+
libpq-dev \
53+
&& apt-get clean \
54+
&& rm -rf /var/lib/apt/lists/*
55+
56+
# Set up virtualenv first
57+
RUN mkdir -p /home/mediacms.io/mediacms/{logs} && \
58+
cd /home/mediacms.io && \
59+
python3 -m venv $VIRTUAL_ENV
60+
61+
# Copy requirements files
62+
COPY requirements.txt requirements-dev.txt ./
63+
64+
# Install Python dependencies using pip (within virtualenv)
65+
ARG DEVELOPMENT_MODE=False
66+
RUN pip install --no-cache-dir uv && \
67+
uv pip install --no-binary lxml --no-binary xmlsec -r requirements.txt && \
68+
if [ "$DEVELOPMENT_MODE" = "True" ]; then \
69+
echo "Installing development dependencies..." && \
70+
uv pip install -r requirements-dev.txt; \
71+
fi && \
72+
apt-get purge -y --auto-remove \
73+
build-essential \
74+
pkg-config \
75+
libxml2-dev \
76+
libxmlsec1-dev \
77+
libpq-dev
78+
79+
# Copy ffmpeg and Bento4 from build image
80+
COPY --from=build-image /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
81+
COPY --from=build-image /usr/local/bin/ffprobe /usr/local/bin/ffprobe
82+
COPY --from=build-image /usr/local/bin/qt-faststart /usr/local/bin/qt-faststart
83+
COPY --from=build-image /home/mediacms.io/bento4 /home/mediacms.io/bento4
84+
85+
# Copy application files
86+
COPY . /home/mediacms.io/mediacms
87+
WORKDIR /home/mediacms.io/mediacms
88+
89+
# required for sprite thumbnail generation for large video files
90+
COPY deploy/docker/policy.xml /etc/ImageMagick-6/policy.xml
91+
92+
# Set process control environment variables
93+
ENV ENABLE_UWSGI='yes' \
94+
ENABLE_NGINX='yes' \
95+
ENABLE_CELERY_BEAT='yes' \
96+
ENABLE_CELERY_SHORT='yes' \
97+
ENABLE_CELERY_LONG='yes' \
98+
ENABLE_MIGRATIONS='yes'
99+
100+
EXPOSE 9000 80
101+
102+
RUN chmod +x ./deploy/docker/entrypoint.sh
103+
104+
ENTRYPOINT ["./deploy/docker/entrypoint.sh"]
105+
CMD ["./deploy/docker/start.sh"]
106+
107+
############ FULL IMAGE ############
108+
FROM base AS full
109+
COPY requirements-full.txt ./
110+
RUN mkdir -p /root/.cache/ && \
111+
chmod go+rwx /root/ && \
112+
chmod go+rwx /root/.cache/
113+
RUN uv pip install -r requirements-full.txt
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
version: "3"
2+
3+
services:
4+
nginx-proxy:
5+
image: nginxproxy/nginx-proxy
6+
container_name: nginx-proxy
7+
ports:
8+
- "80:80"
9+
- "443:443"
10+
volumes:
11+
- conf:/etc/nginx/conf.d
12+
- vhost:/etc/nginx/vhost.d
13+
- html:/usr/share/nginx/html
14+
- dhparam:/etc/nginx/dhparam
15+
- certs:/etc/nginx/certs:ro
16+
- /var/run/docker.sock:/tmp/docker.sock:ro
17+
- ./deploy/docker/reverse_proxy/client_max_body_size.conf:/etc/nginx/conf.d/client_max_body_size.conf:ro
18+
19+
acme-companion:
20+
image: nginxproxy/acme-companion
21+
container_name: nginx-proxy-acme
22+
volumes_from:
23+
- nginx-proxy
24+
volumes:
25+
- certs:/etc/nginx/certs:rw
26+
- acme:/etc/acme.sh
27+
- /var/run/docker.sock:/var/run/docker.sock:ro
28+
29+
migrations:
30+
image: mediacms/mediacms:latest
31+
volumes:
32+
- ./:/home/mediacms.io/mediacms/
33+
environment:
34+
ENABLE_UWSGI: 'no'
35+
ENABLE_NGINX: 'no'
36+
ENABLE_CELERY_SHORT: 'no'
37+
ENABLE_CELERY_LONG: 'no'
38+
ENABLE_CELERY_BEAT: 'no'
39+
ADMIN_USER: 'admin'
40+
ADMIN_EMAIL: 'Y'
41+
ADMIN_PASSWORD: 'X'
42+
command: "./deploy/docker/prestart.sh"
43+
restart: on-failure
44+
depends_on:
45+
redis:
46+
condition: service_healthy
47+
db:
48+
condition: service_healthy
49+
web:
50+
image: mediacms/mediacms:latest
51+
deploy:
52+
replicas: 1
53+
volumes:
54+
- ./:/home/mediacms.io/mediacms/
55+
environment:
56+
ENABLE_CELERY_BEAT: 'no'
57+
ENABLE_CELERY_SHORT: 'no'
58+
ENABLE_CELERY_LONG: 'no'
59+
ENABLE_MIGRATIONS: 'no'
60+
VIRTUAL_HOST: 'X.mediacms.io'
61+
LETSENCRYPT_HOST: 'X.mediacms.io'
62+
LETSENCRYPT_EMAIL: 'X'
63+
depends_on:
64+
- migrations
65+
celery_beat:
66+
image: mediacms/mediacms:latest
67+
volumes:
68+
- ./:/home/mediacms.io/mediacms/
69+
environment:
70+
ENABLE_UWSGI: 'no'
71+
ENABLE_NGINX: 'no'
72+
ENABLE_CELERY_SHORT: 'no'
73+
ENABLE_CELERY_LONG: 'no'
74+
ENABLE_MIGRATIONS: 'no'
75+
depends_on:
76+
- redis
77+
celery_worker:
78+
image: mediacms/mediacms:full
79+
deploy:
80+
replicas: 1
81+
volumes:
82+
- ./:/home/mediacms.io/mediacms/
83+
environment:
84+
ENABLE_UWSGI: 'no'
85+
ENABLE_NGINX: 'no'
86+
ENABLE_CELERY_BEAT: 'no'
87+
ENABLE_MIGRATIONS: 'no'
88+
depends_on:
89+
- migrations
90+
db:
91+
image: postgres:17.2-alpine
92+
volumes:
93+
- ../postgres_data:/var/lib/postgresql/data/
94+
restart: always
95+
environment:
96+
POSTGRES_USER: mediacms
97+
POSTGRES_PASSWORD: mediacms
98+
POSTGRES_DB: mediacms
99+
TZ: Europe/London
100+
healthcheck:
101+
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
102+
interval: 10s
103+
timeout: 5s
104+
retries: 5
105+
redis:
106+
image: "redis:alpine"
107+
restart: always
108+
healthcheck:
109+
test: ["CMD", "redis-cli","ping"]
110+
interval: 10s
111+
timeout: 5s
112+
retries: 3
113+
volumes:
114+
conf:
115+
vhost:
116+
html:
117+
dhparam:
118+
certs:
119+
acme:
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
version: "3"
2+
3+
services:
4+
migrations:
5+
build:
6+
context: .
7+
dockerfile: ./Dockerfile
8+
target: base
9+
args:
10+
- DEVELOPMENT_MODE=True
11+
image: mediacms/mediacms-dev:latest
12+
volumes:
13+
- ./:/home/mediacms.io/mediacms/
14+
command: "./deploy/docker/prestart.sh"
15+
environment:
16+
DEVELOPMENT_MODE: True
17+
ENABLE_UWSGI: 'no'
18+
ENABLE_NGINX: 'no'
19+
ENABLE_CELERY_SHORT: 'no'
20+
ENABLE_CELERY_LONG: 'no'
21+
ENABLE_CELERY_BEAT: 'no'
22+
ADMIN_USER: 'admin'
23+
ADMIN_EMAIL: 'admin@localhost'
24+
ADMIN_PASSWORD: 'admin'
25+
restart: on-failure
26+
depends_on:
27+
redis:
28+
condition: service_healthy
29+
db:
30+
condition: service_healthy
31+
frontend:
32+
image: node:20
33+
volumes:
34+
- ${PWD}/frontend:/home/mediacms.io/mediacms/frontend/
35+
working_dir: /home/mediacms.io/mediacms/frontend/
36+
command: bash -c "npm install && npm run start"
37+
env_file:
38+
- ${PWD}/frontend/.env
39+
ports:
40+
- "8088:8088"
41+
depends_on:
42+
- web
43+
web:
44+
image: mediacms/mediacms-dev:latest
45+
command: "python manage.py runserver 0.0.0.0:80"
46+
environment:
47+
DEVELOPMENT_MODE: True
48+
ports:
49+
- "80:80"
50+
volumes:
51+
- ./:/home/mediacms.io/mediacms/
52+
depends_on:
53+
- migrations
54+
db:
55+
image: postgres:17.2-alpine
56+
volumes:
57+
- ../postgres_data:/var/lib/postgresql/data/
58+
restart: always
59+
environment:
60+
POSTGRES_USER: mediacms
61+
POSTGRES_PASSWORD: mediacms
62+
POSTGRES_DB: mediacms
63+
TZ: Europe/London
64+
healthcheck:
65+
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}", "--host=db", "--dbname=$POSTGRES_DB", "--username=$POSTGRES_USER"]
66+
interval: 10s
67+
timeout: 5s
68+
retries: 5
69+
redis:
70+
image: "redis:alpine"
71+
restart: always
72+
healthcheck:
73+
test: ["CMD", "redis-cli", "ping"]
74+
interval: 30s
75+
timeout: 10s
76+
retries: 3
77+
celery_worker:
78+
image: mediacms/mediacms-dev:latest
79+
deploy:
80+
replicas: 1
81+
volumes:
82+
- ./:/home/mediacms.io/mediacms/
83+
environment:
84+
ENABLE_UWSGI: 'no'
85+
ENABLE_NGINX: 'no'
86+
ENABLE_CELERY_BEAT: 'no'
87+
ENABLE_MIGRATIONS: 'no'
88+
depends_on:
89+
- web

0 commit comments

Comments
 (0)