Skip to content

Commit 43b2ee0

Browse files
committed
Move the new Dockerfile to Dockerfile.experimental
- Moved new Dockerfile to Dockerfile.experimental - Restored previous Dockerfile and added pip/pipenv cache cleanup - Dockerfile can now choose between su-exec/gosu via an environment variable
1 parent 0d3da85 commit 43b2ee0

File tree

3 files changed

+80
-23
lines changed

3 files changed

+80
-23
lines changed

Dockerfile

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG BUILD_DIR=/build
22

3-
# Client Build Container
3+
# Build Container
44
FROM --platform=$BUILDPLATFORM python:3.11-slim-bullseye AS build
55

66
ARG BUILD_DIR
@@ -16,45 +16,36 @@ RUN npm ci
1616
COPY client ./client
1717
RUN npm run build
1818

19-
# Pipenv Build Container
20-
FROM python:3.11-alpine3.19 as pipenv-build
21-
22-
ARG BUILD_DIR
23-
24-
ENV APP_PATH=/app
25-
26-
RUN apk add --no-cache build-base rust cargo libffi libffi-dev libssl3 openssl-dev
27-
28-
RUN pip install --no-cache-dir pipenv
29-
30-
WORKDIR ${APP_PATH}
31-
32-
COPY LICENSE Pipfile Pipfile.lock ./
33-
RUN mkdir .venv
34-
RUN pipenv install --deploy --ignore-pipfile && \
35-
pipenv --clear
36-
3719
# Runtime Container
38-
FROM python:3.11-alpine3.19
20+
FROM python:3.11-slim-bullseye
3921

4022
ARG BUILD_DIR
4123

4224
ENV PUID=1000
4325
ENV PGID=1000
26+
ENV EXEC_TOOL=gosu
4427

4528
ENV APP_PATH=/app
4629
ENV FLATNOTES_PATH=/data
4730

4831
RUN mkdir -p ${APP_PATH}
4932
RUN mkdir -p ${FLATNOTES_PATH}
5033

51-
RUN apk add --no-cache su-exec libssl3 libgcc curl
34+
RUN apt update && apt install -y \
35+
curl \
36+
gosu \
37+
&& rm -rf /var/lib/apt/lists/*
38+
39+
RUN pip install --no-cache-dir pipenv
5240

5341
WORKDIR ${APP_PATH}
5442

43+
COPY LICENSE Pipfile Pipfile.lock ./
44+
RUN pipenv install --deploy --ignore-pipfile --system && \
45+
pipenv --clear
46+
5547
COPY server ./server
5648
COPY --from=build ${BUILD_DIR}/client/dist ./client/dist
57-
COPY --from=pipenv-build ${APP_PATH}/.venv/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/
5849

5950
VOLUME /data
6051
EXPOSE 8080/tcp

Dockerfile.experimental

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
ARG BUILD_DIR=/build
2+
3+
# Client Build Container
4+
FROM --platform=$BUILDPLATFORM python:3.11-slim-bullseye AS build
5+
6+
ARG BUILD_DIR
7+
8+
RUN mkdir ${BUILD_DIR}
9+
WORKDIR ${BUILD_DIR}
10+
11+
RUN apt update && apt install -y npm
12+
13+
COPY package.json package-lock.json .htmlnanorc ./
14+
RUN npm ci
15+
16+
COPY client ./client
17+
RUN npm run build
18+
19+
# Pipenv Build Container
20+
FROM python:3.11-alpine3.19 as pipenv-build
21+
22+
ARG BUILD_DIR
23+
24+
ENV APP_PATH=/app
25+
26+
RUN apk add --no-cache build-base rust cargo libffi libffi-dev libssl3 openssl-dev
27+
28+
RUN pip install --no-cache-dir pipenv
29+
30+
WORKDIR ${APP_PATH}
31+
32+
COPY LICENSE Pipfile Pipfile.lock ./
33+
RUN mkdir .venv
34+
RUN pipenv install --deploy --ignore-pipfile && \
35+
pipenv --clear
36+
37+
# Runtime Container
38+
FROM python:3.11-alpine3.19
39+
40+
ARG BUILD_DIR
41+
42+
ENV PUID=1000
43+
ENV PGID=1000
44+
ENV EXEC_TOOL=su-exec
45+
46+
ENV APP_PATH=/app
47+
ENV FLATNOTES_PATH=/data
48+
49+
RUN mkdir -p ${APP_PATH}
50+
RUN mkdir -p ${FLATNOTES_PATH}
51+
52+
RUN apk add --no-cache su-exec libssl3 libgcc curl
53+
54+
WORKDIR ${APP_PATH}
55+
56+
COPY server ./server
57+
COPY --from=build ${BUILD_DIR}/client/dist ./client/dist
58+
COPY --from=pipenv-build ${APP_PATH}/.venv/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/
59+
60+
VOLUME /data
61+
EXPOSE 8080/tcp
62+
HEALTHCHECK --interval=60s --timeout=10s CMD curl -f http://localhost:8080/health || exit 1
63+
64+
COPY entrypoint.sh /
65+
RUN chmod +x /entrypoint.sh
66+
ENTRYPOINT [ "/entrypoint.sh" ]

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if [ `id -u` -eq 0 ] && [ `id -g` -eq 0 ]; then
3131
chown -R ${PUID}:${PGID} ${FLATNOTES_PATH}
3232

3333
echo Starting flatnotes as user ${PUID}...
34-
exec su-exec ${PUID}:${PGID} ${flatnotes_command}
34+
exec ${EXEC_TOOL} ${PUID}:${PGID} ${flatnotes_command}
3535

3636
else
3737
echo "A user was set by docker, skipping file permission changes."

0 commit comments

Comments
 (0)