-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (45 loc) · 1.65 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
FROM node:18-bookworm-slim as frontend
WORKDIR /home/node/app
COPY package.json package-lock.json ./
RUN npm ci --no-optional --no-audit --progress=false
# The whole project is needed to allow purging of the unused CSS classes.
COPY . .
# Compile static files
RUN npm run build
FROM python:3.11 as backend-production
RUN mkdir /app && mkdir /data
RUN useradd -m lpld -s /bin/bash && \
chown -R lpld /app && \
chown -R lpld /data
WORKDIR /app
# Enable Heroku Exec: https://devcenter.heroku.com/articles/exec#using-with-docker
RUN rm /bin/sh && ln -s /bin/bash /bin/sh && \
apt update -y && apt install -y iproute2 openssh-server
ENV POETRY_HOME=/home/lpld/poetry
ENV PATH=${POETRY_HOME}/bin:$PATH \
# Ensure dependencies are available globally (without having to mess with the poetry's venvs)
POETRY_VIRTUALENVS_CREATE=false \
DJANGO_SETTINGS_MODULE=lpld.settings \
SQLITE_FILE=/data/db.sqlite3 \
PORT=8000
RUN env
# Install litestream
COPY ./scripts/install-litestream.sh ./scripts/
RUN ./scripts/install-litestream.sh
# Install poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN chown -R lpld:lpld ${POETRY_HOME}
# Install Python dependencies
COPY pyproject.toml .
COPY poetry.lock .
RUN poetry install --no-root --no-interaction --no-ansi --without dev
USER lpld
COPY --chown=lpld:lpld . .
COPY --chown=lpld:lpld --from=frontend /home/node/app/lpld/static/comp /app/lpld/static/comp
RUN SECRET_KEY=none ./manage.py collectstatic --noinput --clear
EXPOSE 8000
CMD ./scripts/run.sh
FROM backend-production AS backend-development
USER root
RUN poetry install --no-root --no-interaction --no-ansi --with dev
USER lpld