diff --git a/docker/build.sh b/docker/build.sh index 4212a9df..3edf2c56 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -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 diff --git a/docker/nestrischamps/Dockerfile b/docker/nestrischamps/Dockerfile index 80b4db0f..5ab4486f 100644 --- a/docker/nestrischamps/Dockerfile +++ b/docker/nestrischamps/Dockerfile @@ -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" ]