-
Notifications
You must be signed in to change notification settings - Fork 228
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
O3-2309: Implement dynamic frontend docker images for e2e test #765
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e70e4fa
Dynamic frontend Docker image for e2e test
Piumal1999 eede9c7
Change directory
Piumal1999 13a1269
Fix tests
Piumal1999 85698aa
Update e2e/support/github/run-e2e-docker-env.sh
Piumal1999 97e76bc
Update e2e/support/github/Dockerfile
Piumal1999 b2d5f2f
Fix the port numbers
Piumal1999 f694ded
Merge remote-tracking branch 'origin/frontend-docker' into frontend-d…
Piumal1999 a6846b2
Merge branch 'main' into frontend-docker
Piumal1999 680b9d3
Remove unwanted MFs
Piumal1999 b296407
Remove unwanted MFs
Piumal1999 ecccb23
Remove unwanted MFs
Piumal1999 407e559
Remove unwanted MFs
Piumal1999 fc5dd38
Remove unwanted MFs
Piumal1999 31d2cc6
Test only with login and home apps
Piumal1999 0237936
Test with navigation, chart and home apps
Piumal1999 84fd869
(Breaking) Revert the changes related to #763
Piumal1999 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
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
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,34 @@ | ||
# syntax=docker/dockerfile:1.3 | ||
FROM --platform=$BUILDPLATFORM node:18-alpine as dev | ||
|
||
ARG APP_SHELL_VERSION=next | ||
|
||
RUN mkdir -p /app | ||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN npm_config_legacy_peer_deps=true npm install -g openmrs@${APP_SHELL_VERSION:-next} | ||
ARG CACHE_BUST | ||
RUN npm_config_legacy_peer_deps=true openmrs assemble --manifest --mode config --config spa-assemble-config.json --target ./spa | ||
|
||
FROM --platform=$BUILDPLATFORM openmrs/openmrs-reference-application-3-frontend:nightly as frontend | ||
FROM nginx:1.23-alpine | ||
|
||
RUN apk update && \ | ||
apk upgrade && \ | ||
# add more utils for sponge to support our startup script | ||
apk add --no-cache moreutils | ||
|
||
# clear any default files installed by nginx | ||
RUN rm -rf /usr/share/nginx/html/* | ||
|
||
COPY --from=frontend /etc/nginx/nginx.conf /etc/nginx/nginx.conf | ||
# this assumes that NOTHING in the framework is in a subdirectory | ||
COPY --from=frontend /usr/share/nginx/html/* /usr/share/nginx/html/ | ||
COPY --from=frontend /usr/local/bin/startup.sh /usr/local/bin/startup.sh | ||
RUN chmod +x /usr/local/bin/startup.sh | ||
|
||
COPY --from=dev /app/spa/ /usr/share/nginx/html/ | ||
|
||
CMD ["/usr/local/bin/startup.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
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,49 @@ | ||
#!/usr/bin/env bash -eu | ||
|
||
# get the dir containing the script | ||
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
# create a temporary working directory | ||
working_dir=$(mktemp -d "${TMPDIR:-/tmp/}openmrs-e2e-frontends.XXXXXXXXXX") | ||
# get a list of all the apps in this workspace | ||
apps=$(yarn workspaces list --json | jq -r 'if ((.location == ".") or (.location | test("-app") | not)) then halt else .name end') | ||
# this array will hold all of the packed app names | ||
app_names=() | ||
|
||
echo "Creating packed archives of apps..." | ||
# for each app | ||
for app in $apps | ||
do | ||
# @openmrs/esm-whatever -> _openmrs_esm_whatever | ||
app_name=$(echo "$app" | tr '[:punct:]' '_'); | ||
# add to our array | ||
app_names+=("$app_name.tgz"); | ||
# run yarn pack for our app and add it to the working directory | ||
yarn workspace "$app" pack -o "$working_dir/$app_name.tgz" >/dev/null; | ||
done; | ||
echo "Created packed app archives" | ||
|
||
echo "Creating dynamic spa-assemble-config.json..." | ||
# dynamically assemble our list of frontend modules, prepending the login app and | ||
# primary navigation apps; apps will all be in the /app directory of the Docker | ||
# container | ||
jq -n \ | ||
--arg apps "$apps" \ | ||
--arg app_names "$(echo ${app_names[@]})" \ | ||
'{"@openmrs/esm-primary-navigation-app": "next", "@openmrs/esm-home-app": "next", "@openmrs/esm-patient-chart-app": "next"} + ( | ||
($apps | split("\n")) as $apps | ($app_names | split(" ") | map("/app/" + .)) as $app_files | ||
| [$apps, $app_files] | ||
| transpose | ||
| map({"key": .[0], "value": .[1]}) | ||
| from_entries | ||
)' | jq '{"frontendModules": .}' > "$working_dir/spa-assemble-config.json" | ||
echo "Created dynamic spa-assemble-config.json" | ||
|
||
echo "Copying Docker configuration..." | ||
cp "$script_dir/Dockerfile" "$working_dir/Dockerfile" | ||
cp "$script_dir/docker-compose.yml" "$working_dir/docker-compose.yml" | ||
|
||
cd $working_dir | ||
echo "Starting Docker containers..." | ||
# CACHE_BUST to ensure the assemble step is always run | ||
docker compose build --build-arg CACHE_BUST=$(date +%s) frontend | ||
docker compose up -d |
Oops, something went wrong.
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.
Note: We don't need the
esm-login-app
here because we use the API for login in e2e tests. We can add theesm-offline-tools-app
when we are testing offline features.