Adds Dockerfile to build a container image which hosts diceware

The container is built in two steps (docker builder pattern):

1. Node/npm build stage
2. Final image with Nginx and static files to serve

Build the mage with this command:

    docker image build -t dceware .

Run a container with this command:

    docker run --rm -p 8080:80  dceware

Then you can visit your local diceware at:

http://localhost:8080/

Signed-off-by: Sven Strittmatter <ich@weltraumschaf.de>
This commit is contained in:
Sven Strittmatter 2023-06-06 21:48:29 +02:00 committed by Douglas Muth
parent ab554dde7b
commit 965e503aec

18
Dockerfile Normal file
View file

@ -0,0 +1,18 @@
FROM node:20-bullseye-slim as builder
RUN mkdir /tmp/diceware
COPY . /tmp/diceware/
WORKDIR /tmp/diceware
RUN npm run build
FROM nginx:1.25-bullseye
COPY --from=builder /tmp/diceware/assets /usr/share/nginx/html/assets/
COPY --from=builder /tmp/diceware/dist /usr/share/nginx/html/dist/
COPY --from=builder /tmp/diceware/fonts /usr/share/nginx/html/fonts
COPY --from=builder /tmp/diceware/favicon.ico /usr/share/nginx/html/favicon.ico
COPY --from=builder /tmp/diceware/index.html /usr/share/nginx/html/index.html
COPY --from=builder /tmp/diceware/robots.txt /usr/share/nginx/html/robots.txt
RUN chmod -R a+rX /usr/share/nginx/html