Skip to content

Commit

Permalink
Merge pull request #179 from zohassadar/docker-https-option
Browse files Browse the repository at this point in the history
feat: HTTPS option in docker build
  • Loading branch information
timotheeg authored Jul 27, 2024
2 parents bc469f5 + 39cbf68 commit 5862287
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 19 additions & 2 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
#!/bin/sh
docker-compose build nc
#!/bin/bash

if [[ -n "$HTTPS" ]]; then
echo "Generating self signed cert"
openssl req \
-x509 \
-newkey rsa:4096 \
-keyout key.pem \
-out cert.pem \
-sha256 \
-days 3650 \
-nodes \
-subj "/C=XX/ST=State/L=City/O=NTC/OU=NTC/CN=localhost"
mv ./*.pem nestrischamps/
fi

docker-compose build nc --build-arg HTTPS="$HTTPS"
rm -f nestrischamps/*.pem

docker create -ti --name cpsql nestrischamps bash
docker cp cpsql:/nestrischamps/setup/db.sql postgresql/
docker rm -f cpsql
Expand Down
4 changes: 4 additions & 0 deletions docker/nestrischamps/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ FROM node:18-alpine
RUN apk add git
RUN git clone https://github.com/timotheeg/nestrischamps.git
WORKDIR ./nestrischamps
COPY *.pem ./
ARG HTTPS
ENV TLS_KEY=${HTTPS:+key.pem}
ENV TLS_CERT=${HTTPS:+cert.pem}
RUN npm ci
CMD [ "npm", "run", "start" ]

0 comments on commit 5862287

Please sign in to comment.