-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
82 lines (65 loc) · 2.43 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
FROM python:3.11-alpine AS base
FROM base AS deps
ARG USER_ID
ARG GROUP_ID
ENV USER_ID=$USER_ID
ENV GROUP_ID=$GROUP_ID
RUN addgroup -g $GROUP_ID beetle && adduser -D -u $USER_ID -G beetle beetle
# dependencies
WORKDIR /repo
COPY requirements.txt .
RUN --mount=type=cache,target=/var/cache/apk \
apk --no-cache update
RUN --mount=type=cache,target=/var/cache/apk \
apk --no-cache add imagemagick redis git bash keyfinder-cli npm tmux yq
RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install -r requirements.txt
RUN corepack enable && corepack prepare [email protected] --activate
# our default folders they should not be used in production
RUN mkdir -p /music/inbox
RUN mkdir -p /music/imported
RUN chown -R beetle:beetle /music
# ------------------------------------------------------------------------------------ #
# Development #
# ------------------------------------------------------------------------------------ #
FROM deps AS dev
WORKDIR /repo
COPY --from=deps /repo /repo
COPY entrypoint_dev.sh .
RUN chown -R beetle:beetle /repo
RUN chmod +x ./entrypoint_dev.sh
# we copy config files in the script, so they can be put into mounted volumes
WORKDIR /repo
USER beetle
ENTRYPOINT ["./entrypoint_dev.sh"]
# ------------------------------------------------------------------------------------ #
# Testing #
# ------------------------------------------------------------------------------------ #
FROM deps AS test
WORKDIR /repo
COPY --from=deps /repo /repo
COPY entrypoint_test.sh .
RUN mkdir -p /music/inbox
RUN chown -R beetle:beetle /music/inbox
RUN chown -R beetle:beetle /repo
RUN chmod +x ./entrypoint_test.sh
USER beetle
ENTRYPOINT ["./entrypoint_test.sh"]
# ------------------------------------------------------------------------------------ #
# Production #
# ------------------------------------------------------------------------------------ #
FROM deps AS prod
WORKDIR /repo
COPY --from=deps /repo /repo
COPY --chown=beetle:beetle . .
RUN chmod +x ./entrypoint.sh
WORKDIR /repo/frontend
RUN rm -rf node_modules
RUN rm -rf dist
RUN rm -rf .pnpm-store
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
pnpm install
RUN pnpm run build
WORKDIR /repo
USER beetle
ENTRYPOINT ["./entrypoint.sh"]