-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate cert-renewal process to cloud run job (#79)
Previously, the cert-renewal process was a long standing instance that ran the script once and slept. The problem arises that this sleep eventually breaks and the instance never recovers. This migrates the job to be a cloud run job that runs the script and that is it. The sleep is now handled by a cron schedule. This ensures the instance is always fresh. Fixes #57 Fixes #77
- Loading branch information
1 parent
26b6a1b
commit 1ff0261
Showing
11 changed files
with
398 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,32 +8,26 @@ ENV WPT_HOST=wpt.live \ | |
WPT_ALT_HOST=not-wpt.live \ | ||
WPT_BUCKET=wpt-live | ||
|
||
# Pin the versions for repeatable builds | ||
# Pin the versions of python and google cloud cli for repeatable builds | ||
# For ubuntu package versions, go to https://packages.ubuntu.com/ | ||
# Search for the package with the "jammy" distribution (aka 22.04) selected. | ||
# For Google Cloud, look under https://packages.cloud.google.com/apt/dists/cloud-sdk/main/binary-amd64/Packages | ||
RUN apt-get -qqy update && \ | ||
apt-get -qqy install \ | ||
apt-transport-https=2.4.6 \ | ||
ca-certificates=20211016 \ | ||
curl=7.81.0-1ubuntu1.3 \ | ||
gnupg=2.2.27-3ubuntu2.1 \ | ||
python3=3.10.4-0ubuntu2 \ | ||
python3-dev=3.10.4-0ubuntu2 \ | ||
python3-pip=22.0.2+dfsg-1 && \ | ||
# https://cloud.google.com/storage/docs/gsutil_install | ||
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | \ | ||
tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \ | ||
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \ | ||
tee /usr/share/keyrings/cloud.google.gpg && \ | ||
apt-get -qqy update && \ | ||
apt-get -qqy install \ | ||
google-cloud-cli=396.0.0-0 && \ | ||
rm -rf /var/lib/apt/lists/* && apt-get clean | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg \ | ||
python3=3.10.6-1~22.04 \ | ||
python3-dev=3.10.6-1~22.04 \ | ||
python3-pip=22.0.2+dfsg-1 | ||
# For Google Cloud, look under https://packages.cloud.google.com/apt/dists/cloud-sdk/main/binary-amd64/Packages | ||
# https://cloud.google.com/storage/docs/gsutil_install | ||
# Copy the "Docker Tip" instructions from gsutil_install link and then pin the version | ||
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && apt-get update -y && apt-get install google-cloud-cli=451.0.1-0 -y | ||
|
||
# Instructions for certbot installation | ||
# https://certbot.eff.org/instructions?ws=other&os=pip | ||
RUN pip install certbot==1.29.0 certbot-dns-google==1.29.0 | ||
RUN pip install acme==1.29.0 certbot==1.29.0 certbot-dns-google==1.29.0 | ||
|
||
COPY src/cert-store.sh /usr/local/bin/ | ||
|
||
|
@@ -47,19 +41,16 @@ COPY src/cert-store.sh /usr/local/bin/ | |
# https://eff-certbot.readthedocs.io/en/stable/using.html?highlight=wildcard#dns-plugins | ||
|
||
CMD bash -c '\ | ||
cert-store.sh fetch ${WPT_BUCKET} ${WPT_HOST}; \ | ||
while true; do \ | ||
certbot certonly \ | ||
-d ${WPT_HOST} \ | ||
-d *.${WPT_HOST} \ | ||
-d ${WPT_ALT_HOST} \ | ||
-d *.${WPT_ALT_HOST} \ | ||
--dns-google \ | ||
--dns-google-propagation-seconds 120 \ | ||
--agree-tos \ | ||
--non-interactive \ | ||
--email [email protected] \ | ||
--server https://acme-v02.api.letsencrypt.org/directory \ | ||
--deploy-hook "cert-store.sh save ${WPT_BUCKET} ${WPT_HOST}"; \ | ||
sleep $((60 * 60 * 24)); \ | ||
done' | ||
cert-store.sh fetch ${WPT_BUCKET} ${WPT_HOST} && \ | ||
certbot certonly \ | ||
-d ${WPT_HOST} \ | ||
-d *.${WPT_HOST} \ | ||
-d ${WPT_ALT_HOST} \ | ||
-d *.${WPT_ALT_HOST} \ | ||
--dns-google \ | ||
--dns-google-propagation-seconds 120 \ | ||
--agree-tos \ | ||
--non-interactive \ | ||
--email [email protected] \ | ||
--server https://acme-v02.api.letsencrypt.org/directory \ | ||
--deploy-hook "cert-store.sh save ${WPT_BUCKET} ${WPT_HOST}"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,10 @@ variable "wpt_server_ports" { | |
] | ||
} | ||
|
||
variable "service_account_email" { | ||
type = string | ||
default = "[email protected]" | ||
} | ||
|
||
variable "cert_renewer_ports" { | ||
type = list(object({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.