forked from WordPress/openverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
78 lines (52 loc) · 2.07 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
###################
# Node.js builder #
###################
FROM node:16-alpine as builder
# Install system packages needed to build on macOS
RUN apk add --no-cache --virtual .gyp python3 make g++ \
&& npm install -g pnpm@7.17.1
USER node
WORKDIR /home/node/
# Copy monorepo mocking files into `/home/node`, which pretends to be the monorepo root.
COPY --chown=node:node .npmrc .pnpmfile.cjs pnpm-lock.yaml ./
RUN echo '{"packages":["frontend/"]}' > pnpm-workspace.yaml
# Copy the `frontend/` directory into `/home/node/frontend`, as a package in the monorepo.
COPY --chown=node:node . ./frontend/
# Remove the files copied into `frontend/` by `.github/workflows/ci_cd.yml`.
RUN rm ./frontend/.npmrc ./frontend/.pnpmfile.cjs ./frontend/pnpm-lock.yaml
# Fetch dependencies, including local development tools, to the virtual store.
RUN pnpm fetch
WORKDIR /home/node/frontend
# Prevent pre-commit from being installed, we don't need it here and it fails to install anyway
ENV SKIP_PRE_COMMIT=true
# Get rid of the lockfile as it won't be accurate for the build without workspace.
# Then install dependencies, and in the process:
# - use only dependencies present in the virtual-store
# - fix the missing lockfile by writing a new one
RUN pnpm install --offline
# disable telemetry when building the app
ENV NUXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
ARG API_URL
ARG RELEASE
RUN echo "{\"release\":\"${RELEASE}\"}" > /home/node/frontend/src/static/version.json
RUN pnpm build:only
############
# Nuxt app #
############
FROM node:16-alpine as app
LABEL org.opencontainers.image.source="https://github.com/WordPress/openverse"
# Install CURL for the production healthcheck
RUN apk --no-cache add curl
WORKDIR /home/node/
USER node
COPY --from=builder --chown=node:node /home/node/node_modules ./node_modules/
COPY --from=builder --chown=node:node /home/node/frontend ./frontend/
WORKDIR /home/node/frontend/
# set app serving to permissive / assigned
ENV NUXT_HOST=0.0.0.0
# set application port
ENV PORT=8443
# expose port 8443 by default
EXPOSE 8443
ENTRYPOINT [ "npm", "start", "--" ]