Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nginx reloading when new ssl released #16

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/deploy-atleta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: "recursive"

- name: Create Image Tarball for Explorer
run: |
docker build -t sportchain-explorer -f docker/Dockerfile .
docker save -o sportchain-explorer.tar sportchain-explorer
mkdir -p artifacts/
mv sportchain-explorer.tar artifacts/
docker build --tag sportchain-explorer --file docker/Dockerfile .
docker save --output artifacts/sportchain-explorer.tar sportchain-explorer

- name: Set up SSH
run: |
Expand All @@ -43,5 +42,5 @@ jobs:
key: ${{ secrets.EXPLORER_PRIVATE_KEY }}
script: |
cd /sportchain
docker load -i sportchain-explorer.tar
docker compose up -d
docker load --input sportchain-explorer.tar
docker compose up --detach
12 changes: 10 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ ENV WS_URL=

WORKDIR /usr/share/nginx/html

COPY docker/env.sh .
COPY docker/nginx-container/env.sh .
hrls marked this conversation as resolved.
Show resolved Hide resolved

RUN apk add --no-cache bash; chmod +x env.sh

COPY docker/nginx /etc/nginx
COPY --from=builder /apps/packages/apps/build /usr/share/nginx/html

CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""]
COPY docker/nginx-container/check_ssl.sh /

ENTRYPOINT ["/bin/bash", "-c"]

EXPOSE 80

STOPSIGNAL SIGQUIT

CMD ["/check_ssl.sh & /usr/share/nginx/html/env.sh && exec /docker-entrypoint.sh nginx -g 'daemon off;'"]
3 changes: 2 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
volumes:
- ./nginx/ssl:/etc/nginx/ssl:ro
- ./certbot/www:/var/www/certbot:ro

ports:
- "0.0.0.0:80:80"
- "0.0.0.0:443:443"
Expand All @@ -20,7 +21,7 @@ services:
certbot:
image: certbot/certbot:v2.10.0
container_name: sportchain-explorer-certbot
restart: unless-stopped
restart: always
volumes:
- ./nginx/ssl:/etc/letsencrypt:rw
- ./certbot/www:/var/www/certbot:rw
Expand Down
14 changes: 14 additions & 0 deletions docker/nginx-container/check_ssl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

CERT_DIR="/etc/nginx/ssl/live/polkadot-explorer.atleta.network"
FULLCHAIN_PEM="$CERT_DIR/fullchain.pem"
PRIVKEY_PEM="$CERT_DIR/privkey.pem"
MD5SUM_FILE="/tmp/md5sum"

while true; do
sleep 3600
if [ "$(md5sum "$FULLCHAIN_PEM" "$PRIVKEY_PEM" | md5sum)" != "$(cat "$MD5SUM_FILE" || echo '')" ]; then
nginx -s reload
md5sum "$FULLCHAIN_PEM" "$PRIVKEY_PEM" | md5sum > "$MD5SUM_FILE"
fi
done
File renamed without changes.
Loading