2023-05-23 12:07:25 -07:00
|
|
|
FROM python:3.11-alpine
|
|
|
|
|
2023-05-25 18:33:08 -07:00
|
|
|
# Enforcement to ensure passwords environment variables are not left blank.
|
|
|
|
# This won't stop bad passwords from being used, but at least won't cause
|
|
|
|
# errors or, worse, weaker crypt.
|
|
|
|
ARG POSTGRES_PASSWORD
|
|
|
|
ENV ENV_POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
|
|
|
ARG GHOSTFORGE_JWT_SECRET
|
|
|
|
ENV ENV_GHOSTFORGE_JWT_SECRET=${GHOSTFORGE_JWT_SECRET}
|
|
|
|
RUN [ ! -z "${ENV_POSTGRES_PASSWORD}" ] || { echo "ghostforge build error: Set POSTGRES_PASSWORD in .env."; exit 1; }
|
|
|
|
RUN [ ! -z "${ENV_GHOSTFORGE_JWT_SECRET}" ] || { echo "ghostforge build error: Set GHOSTFORGE_JWT_SECRET in .env."; exit 1; }
|
2023-05-23 13:27:25 -07:00
|
|
|
|
2023-05-25 18:33:08 -07:00
|
|
|
# Create the data directory specified using the environment variables.
|
|
|
|
# This is redundant for mapped volumes, but necessary if the data
|
|
|
|
# directory is specified but not mapped.
|
|
|
|
ARG GHOSTFORGE_DATA_DIR
|
|
|
|
ENV ENV_GHOSTFORGE_DATA_DIR=${GHOSTFORGE_DATA_DIR}
|
|
|
|
RUN mkdir -p "${ENV_GHOSTFORGE_DATA_DIR}"
|
|
|
|
|
|
|
|
# Copy project into Docker image, skipping entries in .dockerignore.
|
2023-05-23 12:07:25 -07:00
|
|
|
WORKDIR /ghostforge
|
|
|
|
COPY . .
|
|
|
|
|
2023-06-02 20:11:02 -07:00
|
|
|
# Install cffi dependencies for pip install.
|
|
|
|
RUN apk add --update --no-cache --virtual ghostforge_build libffi-dev musl-dev gcc
|
|
|
|
|
2023-05-25 18:33:08 -07:00
|
|
|
# Install ghostforge from the work directory.
|
2023-05-23 12:07:25 -07:00
|
|
|
RUN pip install .
|
|
|
|
|
2023-06-02 20:11:02 -07:00
|
|
|
# Remove cffi dependencies for space.
|
|
|
|
RUN apk del ghostforge_build
|
|
|
|
|
2023-05-25 18:33:08 -07:00
|
|
|
# Expose the web "serve" port specific in the environment variables.
|
|
|
|
ARG GHOSTFORGE_INTERNAL_WEB_PORT
|
|
|
|
ENV ENV_GHOSTFORGE_INTERNAL_WEB_PORT=${GHOSTFORGE_INTERNAL_WEB_PORT}
|
|
|
|
EXPOSE ${ENV_GHOSTFORGE_INTERNAL_WEB_PORT}
|
|
|
|
|
2023-06-03 18:07:47 -07:00
|
|
|
ENV PYTHONPATH=/ghostforge
|
2023-05-23 12:07:25 -07:00
|
|
|
|
2023-05-25 18:33:08 -07:00
|
|
|
# TODO: Replace with ghostforge_serve when it works.
|
|
|
|
# This currently just keeps the container running for development.
|
2023-06-02 19:46:04 -07:00
|
|
|
CMD ["sh", "-c", "alembic upgrade head && uvicorn ghostforge.serve:gf --host 0.0.0.0 --port $GHOSTFORGE_INTERNAL_WEB_PORT"]
|