generated from cfpb/open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
54 lines (42 loc) · 1.31 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
### Build Stage ###
# Use node as the base image
FROM node:20-alpine3.19 as build-stage
RUN apk update \
&& apk upgrade \
&& apk cache clean
# Set the working directory to /app
WORKDIR /app
# Copy package.json and package-lock.json to the container
COPY package*.json ./
# Install dependencies
# RUN npm install
RUN yarn set version 4.1.0
COPY yarn.lock .yarn .yarnrc.yml ./
RUN yarn install
# Copy the rest of the project files
COPY . .
# Set Build Version for Footer
ARG DOCKER_TAG
ENV DOCKER_TAG=${DOCKER_TAG}
# Build the Docusaurus project
ENV NODE_ENV=production
ENV BABEL_ENV=production
RUN yarn build
# Remove devDependancies
# RUN npm prune --production
### Run Stage ###
FROM node:20-alpine3.19 as run-stage
# Set the working directory to /app
WORKDIR /app
# Copy files from build-stage
COPY --from=build-stage /app/package.json /app/package.json
COPY --from=build-stage /app/docusaurus.config.js /app/docusaurus.config.js
COPY --from=build-stage /app/sidebars.js /app/sidebars.js
COPY --from=build-stage /app/src /app/src
COPY --from=build-stage /app/node_modules /app/node_modules
COPY --from=build-stage /app/build /app/build
# Non-root user
RUN addgroup -S hmda_group && adduser -S hmda_user -G hmda_group
USER hmda_user
EXPOSE 8080
CMD ["yarn", "run", "serve", "--", "--port", "8080", "--host", "0.0.0.0"]