Files
Yamtrack/Dockerfile
Timothy Stott 9d9f03001e Add IPv6 support
This change remains backward compatible, as IPv6 support is disabled by default.

Nginx fails to start when an IPv6 `listen` directive is specified on an
IPv4-only host, preventing a single configuration from supporting both
protocols. To work around this limitation, the Docker image build
process now generates a separate copy of the Nginx configuration for IPv6.

An environment variable can be used to select either the IPv4 or IPv6
configuration when launching the container.

By embedding both configurations during the image build, we avoid making
file system changes at runtime — a step toward an immutable filesystem design.
2026-01-08 23:45:44 +00:00

42 lines
1.4 KiB
Docker

FROM python:3.12-alpine3.21
# https://stackoverflow.com/questions/58701233/docker-logs-erroneously-appears-empty-until-container-stops
ENV PYTHONUNBUFFERED=1
# Define build argument with default value
ARG VERSION=dev
# Set it as an environment variable
ENV VERSION=$VERSION
COPY ./requirements.txt /requirements.txt
COPY ./entrypoint.sh /entrypoint.sh
COPY ./supervisord.conf /etc/supervisord.conf
COPY ./nginx.conf /etc/nginx/nginx.conf
# Generate a copy of the nginx config with IPv6 support.
RUN sed 's/listen 8000;/listen 8000; listen [::]:8000;/' /etc/nginx/nginx.conf > /etc/nginx/nginx.ipv6.conf
WORKDIR /yamtrack
RUN apk add --no-cache nginx shadow \
&& pip install --no-cache-dir -r /requirements.txt \
&& pip install --no-cache-dir supervisor==4.2.5 \
&& rm -rf /root/.cache /tmp/* \
&& find /usr/local -type d -name __pycache__ -exec rm -rf {} + \
&& chmod +x /entrypoint.sh \
# create user abc for later PUID/PGID mapping
&& useradd -U -M -s /bin/sh abc \
# Create required nginx directories and set permissions
&& mkdir -p /var/log/nginx \
&& mkdir -p /var/lib/nginx/body
# Django app
COPY src ./
RUN python manage.py collectstatic --noinput
EXPOSE 8000
CMD ["/entrypoint.sh"]
HEALTHCHECK --interval=45s --timeout=15s --start-period=30s --retries=5 \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:8000/health/ || exit 1