summaryrefslogtreecommitdiffstats
path: root/Dockerfile
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-04-23 11:16:38 +0100
committerMatthew Lemon <y@yulqen.org>2024-04-23 11:16:38 +0100
commit0f951dcf029d4af284467543a3afdf5bf6581a20 (patch)
treea48384210cdc168e3bd3ccff6d6d516eeed9e748 /Dockerfile
parent8b084e9fe7a5f3a04c32daf9a24f7f2cf67300f9 (diff)
switched to Django
Diffstat (limited to '')
-rw-r--r--Dockerfile54
1 files changed, 20 insertions, 34 deletions
diff --git a/Dockerfile b/Dockerfile
index 71171cc..2cb3f4f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,44 +1,30 @@
-FROM docker.io/golang:alpine
-
-RUN addgroup -S app && adduser -S -g app app
+# Pull base image
+FROM python:3.11.4-slim-bullseye
WORKDIR /app
-RUN apk add --update npm
-RUN npm i sass govuk-frontend --save
-
-# Switch to root user
-USER root
-
-COPY go.mod ./
-RUN go mod download && go mod verify
-
-# instead of doing COPY . . here, I want to be specific about the files I want to copy
-# this way if I add a new file to the project, it will not be copied over
+RUN apt-get update \
+ && apt-get install -y build-essential curl \
+ && rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
+ && apt-get clean \
+ && useradd --create-home python \
+ && chown python:python -R /app
-# Can this be refactored?
-COPY ./cmd ./cmd
-COPY ./internal ./internal
-COPY ./postgresql ./postgresql
-COPY ./ui ./ui
-COPY go.sum .
-COPY go.mod .
-COPY sonar-project.properties .
+USER python
-RUN chown -R app:app /app
+COPY --chown=python:python requirements*.txt ./
-# Create a directory for the binary
-RUN mkdir /app/bin
-RUN chown app:app /app/bin
+RUN pip install -r requirements.txt \
+ && pip install -r requirements_dev.txt
-# Switch back to app user
-USER app
+COPY --chown=python:python . .
-# Build the Go binary in the /app/bin directory
-RUN go build -v -o /app/bin/app ./cmd/web
+ENV DEBUG="${DEBUG}" \
+ PYTHONUNBUFFERED="true" \
+ PATH="${PATH}:/home/python/.local/bin" \
+ USER="python"
-# Set the working directory to /app/bin
-WORKDIR /app/bin
+# Collect static files
+RUN SECRET_KEY=nothing python manage.py collectstatic --no-input
-CMD ["./app"]
-EXPOSE 4000
+CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]