-
Notifications
You must be signed in to change notification settings - Fork 14
/
Dockerfile
48 lines (37 loc) · 1.36 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
# Stage 1: Build frontend assets.
FROM node:23.1.0-alpine as frontend-build
ENV NODE_ENV production
COPY .babelrc rollup.config.js tailwind.config.js gulpfile.js package.json .yarnrc.yml yarn.lock /tmp/frontend-build/
COPY .yarn /tmp/frontend-build/.yarn
COPY lms/static /tmp/frontend-build/lms/static
WORKDIR /tmp/frontend-build
RUN yarn install --immutable
RUN yarn build
# Stage 2: Build the rest of the app using build output from Stage 1.
FROM python:3.11.10-alpine3.19
LABEL authors="Hypothes.is Project and contributors"
# Install system build and runtime dependencies.
RUN apk add libpq supervisor
# Create the lms user, group, home directory and package directory.
RUN addgroup -S lms \
&& adduser -S -G lms -h /var/lib/lms lms
WORKDIR /var/lib/lms
# Copy minimal data to allow installation of dependencies.
COPY requirements/prod.txt ./
# Install build deps, build, and then clean up.
RUN apk add --virtual build-deps \
build-base \
postgresql-dev \
python3-dev \
libffi-dev \
&& pip3 install --no-cache-dir -U pip \
&& pip3 install --no-cache-dir -r prod.txt \
&& apk del build-deps
# Copy frontend assets.
COPY --from=frontend-build /tmp/frontend-build/build build
# Copy the rest of the application files.
COPY . .
ENV PYTHONPATH /var/lib/lms:$PYTHONPATH
EXPOSE 8001
USER lms
CMD ["bin/init-env", "supervisord", "-c", "conf/supervisord.conf"]