Skip to content

Commit e2941b0

Browse files
authored
fix(Dockerfile): remove grimoire user causing problems, limit layers count, simplify Dockerfile (#166)
Signed-off-by: Robert Goniszewski <robertgoniszewski@outlook.com>
1 parent bb40978 commit e2941b0

1 file changed

Lines changed: 36 additions & 12 deletions

File tree

Dockerfile

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
1-
FROM oven/bun AS base
1+
FROM oven/bun AS builder
22
LABEL maintainer="Grimoire Developers <contact@grimoire.pro>"
33
LABEL description="Bookmark manager for the wizards"
44
LABEL org.opencontainers.image.source="https://github.com/goniszewski/grimoire"
55

6-
RUN apt-get update && apt-get install -y python3 python3-pip wget build-essential && \
6+
RUN apt-get update && \
7+
apt-get install -y --no-install-recommends \
8+
xz-utils python3 python3-pip wget build-essential && \
79
rm -rf /var/lib/apt/lists/* && \
8-
bun i -g svelte-kit@latest
10+
mkdir -p /etc/s6-overlay/s6-rc.d/grimoire /etc/s6-overlay/s6-rc.d/user/contents.d
11+
12+
RUN mkdir -p /app/data
13+
14+
ARG S6_OVERLAY_VERSION=3.1.6.2
15+
ARG TARGETARCH=x86_64
16+
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
17+
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${TARGETARCH}.tar.xz /tmp
18+
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz && \
19+
tar -C / -Jxpf /tmp/s6-overlay-${TARGETARCH}.tar.xz && \
20+
rm /tmp/s6-overlay-*xz
21+
22+
COPY docker/etc/s6-overlay /etc/s6-overlay/
23+
RUN chmod +x /etc/s6-overlay/s6-rc.d/grimoire/run
24+
25+
ENV S6_KEEP_ENV=1 \
26+
S6_SERVICES_GRACETIME=15000 \
27+
S6_KILL_GRACETIME=10000 \
28+
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
29+
S6_SYNC_DISKS=1
30+
31+
RUN bun i -g svelte-kit@latest
932

1033
RUN adduser --disabled-password --gecos '' grimoire
1134
RUN mkdir -p /app/data && chown -R grimoire:grimoire /app/data && chmod 766 /app/data
1235
WORKDIR /app
1336

14-
FROM base AS dependencies
37+
FROM builder AS dependencies
1538
COPY package.json bun.lockb ./
16-
RUN bun install --frozen-lockfile
17-
RUN bun install --frozen-lockfile --production
39+
RUN bun install --frozen-lockfile && \
40+
bun install --frozen-lockfile --production
1841

19-
FROM base AS build
42+
FROM builder AS build
2043
COPY --from=dependencies /app/node_modules ./node_modules
2144
COPY . .
2245
RUN bun run svelte-kit sync
@@ -29,24 +52,25 @@ ENV NODE_ENV=production \
2952
NODE_OPTIONS="--max-old-space-size=4096"
3053
RUN bun --bun run build
3154

32-
FROM base AS release
55+
FROM builder AS release
56+
3357
COPY --from=dependencies /app/node_modules ./node_modules
3458
COPY --from=build /app/build ./build
3559
COPY --from=build /app/migrations ./migrations
3660
COPY --from=build /app/migrate.js ./migrate.js
3761
COPY --from=build /app/package.json ./package.json
3862
COPY docker-entrypoint.sh /
63+
COPY docker/etc/ /etc/
3964
ENV NODE_ENV=production \
4065
PUBLIC_ORIGIN=${PUBLIC_ORIGIN:-http://localhost:5173} \
4166
ORIGIN=${PUBLIC_ORIGIN:-http://localhost:5173} \
4267
PORT=${PORT:-5173} \
4368
PUBLIC_HTTPS_ONLY=${PUBLIC_HTTPS_ONLY:-false} \
4469
PUBLIC_SIGNUP_DISABLED=${PUBLIC_SIGNUP_DISABLED:-false} \
4570
BODY_SIZE_LIMIT=${BODY_SIZE_LIMIT:-5000000}
46-
4771
RUN chmod +x /docker-entrypoint.sh
48-
USER grimoire
49-
EXPOSE ${PORT}
72+
EXPOSE ${PORT:-5173}
5073
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
5174
CMD wget --no-verbose --tries=1 --spider http://localhost:$PORT/api/health || exit 1
52-
ENTRYPOINT ["/docker-entrypoint.sh"]
75+
ENTRYPOINT ["/init"]
76+

0 commit comments

Comments
 (0)