-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add dockerfile, scripts, and github workflow * added /_healthz on :1111 Co-authored-by: netpro2k <[email protected]> Co-authored-by: Geng Tan <[email protected]>
- Loading branch information
1 parent
8aa84fc
commit 99db1a7
Showing
5 changed files
with
78 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.git | ||
node_modules |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: spoke | ||
on: | ||
push: | ||
branches: | ||
paths-ignore: ["README.md"] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
turkeyGitops: | ||
uses: mozilla/hubs-ops/.github/workflows/turkeyGitops.yml@master | ||
with: | ||
registry: mozillareality | ||
dockerfile: RetPageOriginDockerfile | ||
secrets: | ||
DOCKER_HUB_PWD: ${{ secrets.DOCKER_HUB_PWD }} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### | ||
# this dockerfile produces image/container that serves customly packaged spoke static files | ||
# the result container should serve reticulum as "spoke_page_origin" on (path) "/spoke/pages" | ||
### | ||
from node:16.13 as builder | ||
run mkdir /spoke && cd /spoke | ||
copy package.json ./ | ||
copy yarn.lock ./ | ||
run yarn install --frozen-lockfile | ||
copy . . | ||
env BASE_ASSETS_PATH="{{rawspoke-base-assets-path}}" | ||
# TODO we should be setting BUILD_VERSION, probably pass in git sha or run number as an ARG | ||
run yarn build 1> /dev/null | ||
run mkdir -p dist/pages && mv dist/*.html dist/pages | ||
# TODO can't we just move this directly from dist to /www ? | ||
run mkdir /spoke/rawspoke && mv dist/pages /spoke/rawspoke && mv dist/assets /spoke/rawspoke | ||
|
||
from alpine/openssl as ssl | ||
run mkdir /ssl && openssl req -x509 -newkey rsa:2048 -sha256 -days 36500 -nodes -keyout /ssl/key -out /ssl/cert -subj '/CN=spoke' | ||
|
||
from nginx:alpine | ||
run apk add bash | ||
run mkdir /ssl && mkdir -p /www/spoke && mkdir -p /www/spoke/pages && mkdir -p /www/spoke/assets | ||
copy --from=ssl /ssl /ssl | ||
copy --from=builder /spoke/rawspoke/pages /www/spoke/pages | ||
copy --from=builder /spoke/rawspoke/assets /www/spoke/assets | ||
copy scripts/docker/nginx.config /etc/nginx/conf.d/default.conf | ||
run echo "1" > /www/_healthz.html | ||
copy scripts/docker/run.sh /run.sh | ||
run chmod +x /run.sh && cat /run.sh | ||
cmd bash /run.sh |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
server { | ||
listen 8080 ssl; | ||
ssl_certificate /ssl/cert; | ||
ssl_certificate_key /ssl/key; | ||
location / { | ||
root /www; | ||
autoindex off; | ||
add_header 'Access-Control-Allow-Origin' '*'; | ||
} | ||
} | ||
|
||
server { | ||
listen 1111; | ||
location =/_healthz { | ||
root /www/_healthz.html; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
find /www/spoke/ -type f -name *.html -exec sed -i "s~{{rawspoke-base-assets-path}}\/~${turkeyCfg_base_assets_path}~g" {} \; | ||
find /www/spoke/ -type f -name *.html -exec sed -i "s~{{rawspoke-base-assets-path}}~${turkeyCfg_base_assets_path}~g" {} \; | ||
find /www/spoke/ -type f -name *.css -exec sed -i "s~{{rawspoke-base-assets-path}}\/~${turkeyCfg_base_assets_path}~g" {} \; | ||
find /www/spoke/ -type f -name *.css -exec sed -i "s~{{rawspoke-base-assets-path}}~${turkeyCfg_base_assets_path}~g" {} \; | ||
|
||
anchor="<!-- DO NOT REMOVE\/EDIT THIS COMMENT - META_TAGS -->" | ||
for f in /www/spoke/pages/*.html; do | ||
for var in $(printenv); do | ||
var=$(echo $var | cut -d"=" -f1 ); prefix="turkeyCfg_"; | ||
[[ $var == $prefix* ]] && sed -i "s/$anchor/ <meta name=\"env:${var#$prefix}\" content=\"${!var//\//\\\/}\"\/> $anchor/" $f; | ||
done | ||
done | ||
nginx -g "daemon off;" |