-
Notifications
You must be signed in to change notification settings - Fork 0
feat: dockerize the site #596
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1789faf
feat: dockerize the site
mcdurdin 16efc4d
chore: temp bootstrap version
mcdurdin bdf0af1
chore: fixup azure deployment workflows for new repo layout
mcdurdin 48594e8
chore: Merge branch 'staging' into feat/dockerize
mcdurdin 1b9cdd9
chore: v1.0.10 shared sites
mcdurdin b85a98e
chore: address review comments, add docs, and cleanup
mcdurdin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,4 @@ | ||
|
|
||
| Dockerfile text eol=lf | ||
| *.Dockerfile text eol=lf | ||
| *.sh eol=lf |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,4 +1,15 @@ | ||
| localenv.sh | ||
| node_modules/ | ||
| .keymanapp-test-bot.* | ||
| local*.sh | ||
| local*.sh | ||
|
|
||
| # Shared files are bootstrapped: | ||
| resources/bootstrap.inc.sh | ||
| resources/.bootstrap-version | ||
| resources/.bootstrap-registry | ||
| _common/ | ||
|
|
||
| # State files | ||
| _control/debug | ||
| _control/release | ||
| _control/ready |
This file contains hidden or 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
Empty file.
This file contains hidden or 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,94 @@ | ||
| #!/usr/bin/env bash | ||
| ## START STANDARD SITE BUILD SCRIPT INCLUDE | ||
| readonly THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")" | ||
| readonly BOOTSTRAP="$(dirname "$THIS_SCRIPT")/resources/bootstrap.inc.sh" | ||
| # TODO: release updated bootstrap version! | ||
| readonly BOOTSTRAP_VERSION=feat/docker-support-for-status-site | ||
| [ -f "$BOOTSTRAP" ] && source "$BOOTSTRAP" || source <(curl -H "Cache-Control: no-cache" -fs https://raw.githubusercontent.com/keymanapp/shared-sites/$BOOTSTRAP_VERSION/bootstrap.inc.sh) | ||
| ## END STANDARD SITE BUILD SCRIPT INCLUDE | ||
|
|
||
| # | ||
| # in development mode, the public host is on a separate port to reduce the | ||
| # complexity of tsc --watch vs nodemon; in the future we could consider | ||
| # consolidation into a single container. There is little benefit into splitting | ||
| # production into two containers, given production version of public is fully | ||
| # static on server side. | ||
| # | ||
|
|
||
| source _common/keyman-local-ports.inc.sh | ||
| source _common/docker.inc.sh | ||
|
|
||
| readonly HOST_STATUS_KEYMAN_COM=status.keyman.com.localhost | ||
|
|
||
| readonly THIS_CONTAINER_NAME=status-keyman-website | ||
| readonly PUBLIC_CONTAINER_NAME=status-keyman-public | ||
| readonly THIS_CONTAINER_DESC=status-keyman-com-app | ||
| readonly PUBLIC_CONTAINER_DESC=status-keyman-com-public | ||
| readonly THIS_IMAGE_NAME=status-keyman-website | ||
| readonly PUBLIC_IMAGE_NAME=status-keyman-public | ||
| readonly THIS_HOST="$HOST_STATUS_KEYMAN_COM" | ||
| readonly PUBLIC_HOST="$HOST_STATUS_KEYMAN_COM" # same host | ||
| readonly THIS_PORT="$PORT_STATUS_KEYMAN_COM" | ||
| readonly PUBLIC_PORT="$PORT_STATUS_KEYMAN_COM_PUBLIC" | ||
|
|
||
|
|
||
| ################################ Main script ################################ | ||
|
|
||
| builder_describe \ | ||
| "Setup status.keyman.com site to run via Docker." \ | ||
| configure \ | ||
| clean \ | ||
| build \ | ||
| start \ | ||
| stop \ | ||
| test | ||
|
|
||
| builder_parse "$@" | ||
|
|
||
| function build_docker_containers() { | ||
| build_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME $BUILDER_CONFIGURATION server.Dockerfile | ||
| if builder_is_debug_build; then | ||
| build_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME $BUILDER_CONFIGURATION public.Dockerfile | ||
| fi | ||
| } | ||
|
|
||
| function start_docker_containers() { | ||
| start_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME $THIS_CONTAINER_DESC $THIS_HOST $THIS_PORT $BUILDER_CONFIGURATION | ||
| if builder_is_debug_build; then | ||
| start_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME $PUBLIC_CONTAINER_DESC $PUBLIC_HOST $PUBLIC_PORT $BUILDER_CONFIGURATION | ||
| fi | ||
| } | ||
|
|
||
| function stop_docker_containers() { | ||
| rm -f ./_control/ready | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why wouldn't this be in clean_docker_containers?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because once the site is down, it is no longer ready -- it could go in clean as well I guess? |
||
| stop_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME | ||
| # always stop all containers - even in release build | ||
| stop_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME | ||
| } | ||
|
|
||
| function clean_docker_containers() { | ||
| clean_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME | ||
| # always clean all containers - even in release build | ||
| clean_docker_container $PUBLIC_IMAGE_NAME $PUBLIC_CONTAINER_NAME | ||
| } | ||
|
|
||
| function do_clean() { | ||
| clean_docker_containers | ||
| rm -rf ./server/node_modules ./server/dist | ||
| rm -rf ./public/node_modules ./public/angular ./public/dist | ||
| rm -rf ./public/angular | ||
| rm -rf ./_common | ||
| rm -rf ./resources/.bootstrap-registry ./resources/bootstrap-version ./resources/bootstrap.inc.sh | ||
| } | ||
|
|
||
| function test_docker_container() { | ||
| stop_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME | ||
| MSYS_NO_PATHCONV=1 start_docker_container $THIS_IMAGE_NAME $THIS_CONTAINER_NAME $THIS_CONTAINER_DESC $THIS_HOST $THIS_PORT $BUILDER_CONFIGURATION "/bin/sh" "./resources/test.sh" | ||
| } | ||
|
|
||
| builder_run_action configure bootstrap_configure | ||
| builder_run_action clean do_clean | ||
| builder_run_action stop stop_docker_containers | ||
| builder_run_action build build_docker_containers | ||
| builder_run_action start start_docker_containers | ||
| builder_run_action test test_docker_container | ||
This file contains hidden or 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 hidden or 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 @@ | ||
| # syntax=docker/dockerfile:1 | ||
|
|
||
| FROM node:22@sha256:cd6fb7efa6490f039f3471a189214d5f548c11df1ff9e5b181aa49e22c14383e AS node-builder | ||
|
|
||
| WORKDIR /var/www/html | ||
|
|
||
| ARG BUILDER_CONFIGURATION="debug" | ||
| ENV BUILDER_CONFIGURATION=$BUILDER_CONFIGURATION | ||
|
|
||
| # DOCKER_RUNTIME_PUBLIC env var helps prevent the resource scripts running on the host | ||
| ENV DOCKER_RUNTIME_PUBLIC=1 | ||
|
|
||
| CMD [ "/bin/sh", "./resources/start-public.sh" ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary to specify
--debugor is that the default (as it is with the builder scripts in the keyman repo)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently,
--debugis not default.