Skip to content

Example usage

Andrew Hosgood edited this page Oct 14, 2024 · 4 revisions

Simple example Dockerfile

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

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

# Install dependencies
RUN tna-build

# Run the application
CMD ["tna-run", "my_application: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-root
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 pass it in
# as an envrironment variable which will allow you to output the build version
# in the code
# https://github.com/nationalarchives/ds-docker-actions/blob/main/.github/actions/docker-build/action.yml#L34
ARG BUILD_VERSION
ENV BUILD_VERSION="$BUILD_VERSION"

# 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 and tests
RUN rm -fR /app/src /app/test

# Run the application
CMD ["tna-run", "my_application:app"]
Clone this wiki locally