Skip to content

Commit 7007fff

Browse files
authored
支持证书自签发续订 (#367)
* 支持证书自签发续订 * 修复docker 构建
1 parent 7a1a536 commit 7007fff

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

.github/workflows/docker-images-reusable.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ jobs:
153153
154154
- name: Manifest Docker Image
155155
run: |
156-
docker manifest create ${{ steps.set-tag.outputs.TAGS }} \
156+
docker buildx imagetools create -t ${{ steps.set-tag.outputs.TAGS }} \
157157
${{ steps.set-tag.outputs.AMD_TAGS }} \
158-
${{ steps.set-tag.outputs.ARM_TAGS }}
159-
docker manifest push ${{ steps.set-tag.outputs.TAGS }}
158+
${{ steps.set-tag.outputs.ARM_TAGS }}

deployment/helm/datamate/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public:
4141
data:
4242
DB_PASSWORD: "password"
4343
CERT_PASS: ""
44+
DOMAIN: ""
4445

4546
datasetVolume: &datasetVolume
4647
name: dataset-volume
@@ -177,6 +178,11 @@ frontend:
177178
secretKeyRef:
178179
name: datamate-conf
179180
key: CERT_PASS
181+
- name: DOMAIN
182+
valueFrom:
183+
secretKeyRef:
184+
name: datamate-conf
185+
key: DOMAIN
180186
volumes:
181187
- *logVolume
182188
- name: cert-volume

scripts/images/frontend/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ FROM nginx:1.29 AS runner
1212
RUN --mount=type=cache,target=/var/cache/apt \
1313
--mount=type=cache,target=/var/lib/apt \
1414
apt update \
15-
&& apt install -y dos2unix
15+
&& apt install -y dos2unix python3 python3-dev python3-venv libaugeas-dev gcc \
16+
&& python3 -m venv /opt/certbot/ \
17+
&& /opt/certbot/bin/pip install --upgrade pip \
18+
&& /opt/certbot/bin/pip install certbot certbot-nginx \
19+
&& ln -s /opt/certbot/bin/certbot /usr/local/bin/certbot
1620

1721
COPY --from=builder /app/dist /opt/frontend/statics
1822
COPY scripts/images/frontend/routes.inc /opt/frontend/routes.inc

scripts/images/frontend/start.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ if [ -f "/etc/nginx/cert/server.pem" ]; then
2121
else
2222
cp /opt/frontend/http_backend.conf /etc/nginx/conf.d/default.conf
2323
cp /opt/frontend/routes.inc /etc/nginx/conf.d/routes.inc
24-
echo "Switching to HTTP config"
24+
25+
if [ -n "$DOMAIN" ]; then
26+
cron
27+
certbot --nginx "-d ${DOMAIN//,/ -d }"
28+
echo "Switching to HTTPS config, Domain: $DOMAIN"
29+
echo "0 0 1 * * root /usr/local/bin/certbot renew --quiet" | tee /etc/cron.d/certbot-renew
30+
chmod 0644 /etc/cron.d/certbot-renew
31+
else
32+
echo "Switching to HTTP config"
33+
fi
2534
fi
2635

2736
exec nginx -g "daemon off;"

0 commit comments

Comments
 (0)