Added Docker support

This commit is contained in:
Douglas Muth 2023-06-10 12:54:19 -04:00
parent 965e503aec
commit 0a93c9e8c4
6 changed files with 68 additions and 0 deletions

View File

@ -16,3 +16,4 @@ 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

View File

@ -91,6 +91,16 @@ A local webserver can be set up by running `npm install http-server -g` to insta
- `gh release upload v1.0.1 diceware.zip` to upload the ZIP file containing everything
## Development In Docker
Wanna develop in Docker? We got you covered. Here are some helper scripts:
- `bin/docker-build.sh` - Build the Docker copntainer
- `bin/docker-dev.sh` - Run in dev mode--listening on http://localhost:8000/
- `bin/docker-prod.sh` - Run in prod mode--listening on http://localhost:80/
- `bin/docker-push.sh` - Push to Docker Hub
# Who built this? / Contact
My name is Douglas Muth, and I am a software engineer in Philadelphia, PA.

13
bin/docker-build.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
#
# Build our Docker image.
#
# Errors are fatal
set -e
# Change to the parent directory of this script
pushd $(dirname $0)/.. > /dev/null
docker build -t diceware . -f ./Dockerfile

16
bin/docker-dev.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
#
# Script to run the script in dev mode, which will spawn a shell
#
# Errors are fatal
set -e
# Change to the parent directory
pushd $(dirname $0)/.. > /dev/null
PORT=${PORT:=8000}
docker run --rm -it -p ${PORT}:80 -v $(pwd):/mnt diceware

13
bin/docker-prod.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
#
# Script to run the script in prod mode
#
# Errors are fatal
set -e
# Change to the parent directory
pushd $(dirname $0)/.. > /dev/null
docker run --rm -p 80:80 diceware

15
bin/docker-push.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
#
# Push our Docker image our Docker Hub.
#
# Errors are fatal
set -e
# Change to the parent directory of this script
pushd $(dirname $0)/.. > /dev/null
docker tag diceware dmuth1/diceware
docker push dmuth1/diceware