Skip to content

Example usage

Andrew Hosgood edited this page Dec 8, 2025 · 7 revisions

Simple example Dockerfile

FROM ghcr.io/nationalarchives/tna-python:latest

# Copy in the application code
COPY --chown=app . .

# Install dependencies
RUN tna-build

# Clean up build dependencies
RUN tna-clean

# Run the application
CMD ["tna-wsgi", "main:app"]

Advanced example Dockerfile

# This allows you to pass a build argument to change the image to a root level
# one such as tna-python-dev
ARG IMAGE=ghcr.io/nationalarchives/tna-python

# This allows you to pass a build argument to change the base image version,
# for example in your local env, you could use the preview image
ARG IMAGE_TAG=latest

FROM "$IMAGE":"$IMAGE_TAG"

# Using the Docker build scripts, you can accept a BUILD_VERSION and
# CONTAINER_IMAGE and pass it in as an environment variable which will
# allow you to output the build version from the CI/CD into the code
# https://github.com/nationalarchives/ds-docker-actions/blob/main/.github/actions/build/action.yml#L73
ARG BUILD_VERSION
ENV BUILD_VERSION="$BUILD_VERSION"
ARG CONTAINER_IMAGE
ENV CONTAINER_IMAGE="$CONTAINER_IMAGE"

# Provide a build command used from your package.json to build Node assets
ENV NPM_BUILD_COMMAND=compile

# Copy in the application code
COPY --chown=app . .

# Install dependencies
RUN tna-build

# Delete source files
RUN rm -fR /app/src

# Clean up build dependencies
RUN tna-clean

# Run the application
CMD ["tna-wsgi", "main:app"]

Clone this wiki locally