35 lines
1.4 KiB
Docker
35 lines
1.4 KiB
Docker
# Stage 1: Extract static assets from the Airflow image
|
|
FROM pangramia/ytdlp-ops-airflow:latest AS asset-extractor
|
|
|
|
# Switch to root to create and write to the /assets directory
|
|
USER root
|
|
|
|
# Create a temporary directory for extracted assets
|
|
WORKDIR /assets
|
|
|
|
# Copy static assets from the Airflow image.
|
|
# This dynamically finds the paths to flask_appbuilder and airflow static assets
|
|
# to be resilient to version changes.
|
|
RUN cp -R $(python -c 'import os, flask_appbuilder; print(os.path.join(os.path.dirname(flask_appbuilder.__file__), "static"))') ./appbuilder && \
|
|
cp -R $(python -c 'import os, airflow; print(os.path.join(os.path.dirname(airflow.__file__), "www/static/dist"))') ./dist
|
|
|
|
# Pre-compress the static assets using gzip
|
|
# This improves performance by allowing Caddy to serve compressed files directly.
|
|
RUN find ./appbuilder -type f -print0 | xargs -0 gzip -k -9 && \
|
|
find ./dist -type f -print0 | xargs -0 gzip -k -9
|
|
|
|
|
|
# Stage 2: Build the final Caddy image
|
|
FROM caddy:2-alpine
|
|
|
|
# Copy the pre-compressed static assets from the first stage
|
|
COPY --from=asset-extractor /assets/appbuilder /usr/share/caddy/static/appbuilder
|
|
COPY --from=asset-extractor /assets/dist /usr/share/caddy/static/dist
|
|
|
|
# Copy the Caddyfile configuration. The build context is the project root,
|
|
# so the path is relative to that.
|
|
COPY configs/Caddyfile /etc/caddy/Caddyfile
|
|
|
|
# Expose the port Caddy listens on
|
|
EXPOSE 8080
|