hubl/internal/docker/front.docker

38 lines
911 B
Docker
Raw Normal View History

2020-05-19 13:13:30 +00:00
FROM node:12 AS builder
LABEL maintainer="Plup <plup@plup.io>"
# install dependencies
WORKDIR /build
ADD package.json package-lock.json ./
ADD src/ src/
RUN npm install --only=production
# build the app
ADD docker/config.json .
RUN npm run build
# change index to template
RUN mv /build/dist/index.html /build/dist/index.tpl
# generate a self signed certificate
RUN openssl req -x509 -newkey rsa:4096 -keyout /tmp/key.pem -out /tmp/cert.pem -days 365 -nodes -subj '/CN=localhost'
# serve
FROM nginx:latest
COPY --from=builder /build/dist /var/www
COPY --from=builder /tmp/*.pem /etc/nginx/
WORKDIR /var/www
# get specific config
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 443
# get server address
ENV SERVER http://localhost:8000
# replace addresses at runtime
CMD /bin/bash -c "envsubst '\$SERVER' < index.tpl > index.html && \
exec nginx -g 'daemon off;'"
# vim: ft=dockerfile: