From 2dba19a77e4b9d5cc12b062c03df43743bfbd02f Mon Sep 17 00:00:00 2001 From: badbl0cks <4161747+badbl0cks@users.noreply.github.com> Date: Tue, 6 May 2025 23:14:36 -0700 Subject: [PATCH] Small refactor of scripts, Dockerfile, and docker-compose to support load balancing, and mutiple replicas. Various fixes related to playwright installation in container environment, static file handling, and etc. --- Dockerfile | 79 ++++++++----------- deploy.sh | 5 -- docker-compose.yml | 17 +++- docker-compose_prod.yml | 26 ++++-- package-lock.json | 21 ----- package.json | 5 -- scripts/deploy.sh | 5 ++ scripts/entrypoint.sh | 34 ++++---- scripts/prebuild.sh | 12 +++ scripts/rebuild-and-run.sh | 9 +++ scripts/reset-db_make-migrations_seed-data.sh | 23 +----- staticfiles/.gitkeep | 0 12 files changed, 109 insertions(+), 127 deletions(-) delete mode 100755 deploy.sh delete mode 100644 package-lock.json delete mode 100644 package.json create mode 100755 scripts/deploy.sh create mode 100755 scripts/prebuild.sh create mode 100755 scripts/rebuild-and-run.sh create mode 100644 staticfiles/.gitkeep diff --git a/Dockerfile b/Dockerfile index 2db38aa..5dd6f4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,16 @@ # syntax=docker/dockerfile:1.9 -FROM python3.13-slim-bookworm AS build +### Start build prep. +### This should be a separate build container for better reuse. +FROM python:3.13-slim-bookworm AS build # The following does not work in Podman unless you build in Docker # compatibility mode: # You can manually prepend every RUN script with `set -ex` too. SHELL ["sh", "-exc"] -# Ensure apt-get doesn't open a menu on you. +# Ensure apt-get doesn't open a menu ENV DEBIAN_FRONTEND=noninteractive -### Start build prep. -### This should be a separate build container for better reuse. - -# RUN <. STOPSIGNAL SIGINT -# Copy the pre-built `/app` directory to the runtime container -# and change the ownership to user app and group app in one step. COPY --from=build --chown=app:app /app /app +RUN playwright install --with-deps + # If your application is NOT a proper Python package that got # pip-installed above, you need to copy your application into -# the container HERE: -COPY . /code - -USER app -#WORKDIR /app # If python-packaged -WORKDIR /code # If not python-packaged - -# Strictly optional, but I like it for introspection of what I've built -# and run a smoke test that the application can, in fact, be imported. -# RUN <