2023-03-25 16:49:04 -05:00
|
|
|
# Multi-stage
|
|
|
|
# 1) Node image for building frontend assets
|
|
|
|
# 2) nginx stage to serve frontend assets
|
|
|
|
|
|
|
|
# Name the node stage "builder"
|
2023-07-04 19:52:25 -05:00
|
|
|
FROM docker.io/node:16 AS builder
|
2023-03-25 16:49:04 -05:00
|
|
|
# Set working directory
|
|
|
|
WORKDIR /app
|
2023-04-10 15:33:11 -05:00
|
|
|
|
2023-06-13 11:43:19 -05:00
|
|
|
ENV SAFETWITCH_BACKEND_DOMAIN SAFETWITCH_BACKEND_DOMAIN_PLACEHOLDER
|
|
|
|
ENV SAFETWITCH_INSTANCE_DOMAIN SAFETWITCH_INSTANCE_DOMAIN_PLACEHOLDER
|
|
|
|
ENV SAFETWITCH_HTTPS SAFETWITCH_HTTPS_PLACEHOLDER
|
2023-03-25 16:49:04 -05:00
|
|
|
# Copy all files from current directory to working dir in image
|
|
|
|
COPY . .
|
|
|
|
# install node modules and build assets
|
|
|
|
RUN npm i && npm run build
|
|
|
|
|
|
|
|
# nginx state for serving content
|
2023-07-04 19:52:25 -05:00
|
|
|
FROM docker.io/nginx:alpine
|
2023-03-26 18:11:06 -05:00
|
|
|
COPY ./nginx.conf /etc/nginx/nginx.conf
|
2023-03-25 16:49:04 -05:00
|
|
|
# Set working directory to nginx asset directory
|
2023-04-26 09:31:07 -05:00
|
|
|
RUN mkdir /app
|
2023-03-25 16:49:04 -05:00
|
|
|
# Copy static assets from builder stage
|
2023-04-26 09:31:07 -05:00
|
|
|
COPY --from=builder /app/dist /app
|
2023-03-25 16:49:04 -05:00
|
|
|
# Containers run nginx with global directives and daemon off
|
2023-03-25 20:50:45 -05:00
|
|
|
EXPOSE 80
|
2023-04-26 09:31:07 -05:00
|
|
|
|
|
|
|
# Overriding the default NGINX container behavior
|
|
|
|
COPY ./substitute_environment_variables.sh ./substitute_environment_variables.sh
|
|
|
|
RUN chmod +x /substitute_environment_variables.sh
|
|
|
|
ENTRYPOINT ["/substitute_environment_variables.sh"]
|