aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/static-preview.yaml7
-rw-r--r--Dockerfile6
-rw-r--r--static-builds/Dockerfile28
-rw-r--r--static-builds/README.md2
4 files changed, 11 insertions, 32 deletions
diff --git a/.github/workflows/static-preview.yaml b/.github/workflows/static-preview.yaml
index 970fad99..06192f02 100644
--- a/.github/workflows/static-preview.yaml
+++ b/.github/workflows/static-preview.yaml
@@ -38,7 +38,6 @@ jobs:
if: github.ref == 'refs/heads/main'
with:
context: .
- file: ./static-builds/Dockerfile
push: true
cache-from: type=registry,ref=ghcr.io/python-discord/static-site:latest
cache-to: type=inline
@@ -47,12 +46,14 @@ jobs:
ghcr.io/python-discord/static-site:${{ steps.sha_tag.outputs.tag }}
build-args: |
git_sha=${{ github.sha }}
+ STATIC_BUILD=TRUE
- name: Extract Build From Docker Image (Main)
if: github.ref == 'refs/heads/main'
run: |
mkdir docker_build \
- && docker run --name site ghcr.io/python-discord/static-site:${{ steps.sha_tag.outputs.tag }} \
+ && docker run --entrypoint /bin/echo --name site \
+ ghcr.io/python-discord/static-site:${{ steps.sha_tag.outputs.tag }} \
&& docker cp site:/app docker_build/
# Build directly to a local folder
@@ -61,12 +62,12 @@ jobs:
if: github.ref != 'refs/heads/main'
with:
context: .
- file: ./static-builds/Dockerfile
push: false
cache-from: type=registry,ref=ghcr.io/python-discord/static-site:latest
outputs: type=local,dest=docker_build/
build-args: |
git_sha=${{ github.sha }}
+ STATIC_BUILD=TRUE
- name: Upload Build
uses: actions/upload-artifact@v2
diff --git a/Dockerfile b/Dockerfile
index 046e7f80..2b039fab 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -36,6 +36,12 @@ RUN \
METRICITY_DB_URL=postgres://localhost \
python manage.py collectstatic --noinput --clear
+# Build static files if we are doing a static build
+ARG STATIC_BUILD=false
+RUN if [ $STATIC_BUILD = "TRUE" ] ; \
+ then SECRET_KEY=dummy_value python manage.py distill-local build --traceback --force ; \
+fi
+
# Run web server through custom manager
ENTRYPOINT ["python", "manage.py"]
CMD ["run"]
diff --git a/static-builds/Dockerfile b/static-builds/Dockerfile
deleted file mode 100644
index a70165a0..00000000
--- a/static-builds/Dockerfile
+++ /dev/null
@@ -1,28 +0,0 @@
-# Build a static preview of the site
-FROM --platform=linux/amd64 python:3.9-slim-buster
-
-# Allow service to handle stops gracefully
-STOPSIGNAL SIGQUIT
-
-# Set pip to have cleaner logs and no saved cache
-ENV PIP_NO_CACHE_DIR=false \
- POETRY_VIRTUALENVS_CREATE=false
-
-# Install poetry
-RUN pip install -U poetry
-
-# Copy the project files into working directory
-WORKDIR /app
-
-# Install project dependencies
-COPY pyproject.toml poetry.lock ./
-RUN poetry install --no-dev
-
-ARG git_sha="development"
-ENV GIT_SHA=$git_sha
-ENV PARENT_HOST=replace_me.host
-
-# Copy the source code in last to optimize rebuilding the image
-COPY . .
-
-RUN SECRET_KEY=dummy_value python manage.py distill-local build --traceback --force --collectstatic
diff --git a/static-builds/README.md b/static-builds/README.md
index ee2c0910..fe24df07 100644
--- a/static-builds/README.md
+++ b/static-builds/README.md
@@ -21,7 +21,7 @@ python -m pip install httpx==0.19.0
python manage.py distill-local build --traceback --force --collectstatic
```
-Alternatively, you can use the [Dockerfile](./Dockerfile) in this folder.
+Alternatively, you can use the [Dockerfile](/Dockerfile) and extract the build.
Both output their builds to a `build/` directory.