Skip to content

Commit b2865f3

Browse files
committed
* 'main' of https://github.com/UW-Macrostrat/corelle: Frontend image Updated frontend bundling Deduplicated @macrostrat/svg-map-components Attempt to fix issue with production Improved styling Updated packages
2 parents ca57dd1 + 736be79 commit b2865f3

File tree

21 files changed

+1245
-457
lines changed

21 files changed

+1245
-457
lines changed

.github/workflows/build-push.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build Corelle API image
2+
3+
permissions: read-all
4+
5+
on:
6+
push:
7+
branches: ["main"]
8+
tags:
9+
- "v*.*.*" # glob for semver tags (including prereleases)
10+
pull_request:
11+
branches: [main]
12+
13+
jobs:
14+
build-api-image:
15+
uses: UW-Macrostrat/build-push/.github/workflows/build-push.yaml@main
16+
secrets: inherit
17+
with:
18+
context: .
19+
image: "hub.opensciencegrid.org/macrostrat/corelle-api"
20+
21+
build-frontend-image:
22+
uses: UW-Macrostrat/build-push/.github/workflows/build-push.yaml@main
23+
secrets: inherit
24+
with:
25+
context: ./frontend
26+
file: ./frontend/Dockerfile
27+
image: "hub.opensciencegrid.org/macrostrat/corelle-frontend"

frontend/.dockerignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
.cache
2-
dist
3-
node_modules
2+
.yarn/cache
3+
.yarn/unplugged
4+
.yarn/install-state.gz
5+
.pnp.cjs
6+
.pnp.loader.mjs
7+
.env
8+
.env.local
9+
packages/demo-app/dist
10+
packages/demo-app/node_modules
11+
Dockerfile
12+
scripts

frontend/.yarn/releases/yarn-4.9.4.cjs

Lines changed: 942 additions & 0 deletions
Large diffs are not rendered by default.

frontend/.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
pnpFallbackMode: all
2+
23
pnpMode: loose
4+
5+
yarnPath: .yarn/releases/yarn-4.9.4.cjs

frontend/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## [2025-09-02]
2+
3+
- Upgrade the demo app to compile using Vite
4+
- Pull in environment variables at runtime.

frontend/Dockerfile

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,51 @@
1-
FROM node:12
1+
FROM node:20 AS builder
22

3-
WORKDIR /app/
4-
COPY package.json /app/
3+
# The following build sequence is adapted from the Macrostrat web repository
4+
# Install rsync
5+
RUN apt-get update && apt-get install -y rsync
56

6-
RUN npm install -g parcel-bundler && npm install
7+
ENV NODE_ENV=production
78

8-
COPY ./ /app/
9+
WORKDIR /usr/src/app
10+
COPY .yarn/releases .yarn/releases
11+
COPY .yarnrc.yml yarn.lock package.json ./
12+
13+
# Copy only the elements needed for a Yarn install to take advantage of
14+
# Docker's layer caching
15+
# This is complex because we are working with multiple workspaces.
16+
17+
# Copy package JSON files with wildcards
18+
# This scoops up all package.json files in the directory and subdirectories
19+
# to deal with Yarn workspaces. However it requires BUILDKIT to be enabled,
20+
# which is done by setting DOCKER_BUILDKIT=1 in the environment
21+
RUN --mount=type=bind,target=/docker-context \
22+
cd /docker-context/; \
23+
find . -name "package.json" -mindepth 0 -maxdepth 5 -exec cp --parents "{}" /usr/src/app/ \;
24+
25+
# Load the cache from the previous build
26+
RUN --mount=type=cache,target=/yarn-cache \
27+
rsync -a /yarn-cache/ .yarn/cache/ \
28+
&& yarn install --immutable \
29+
&& rsync -a .yarn/cache/ /yarn-cache
30+
31+
# # Remove rsync
32+
RUN apt-get remove -y rsync
33+
34+
COPY . ./
35+
36+
ENV NODE_ENV=development
37+
38+
RUN yarn run build:demo-app
39+
40+
FROM caddy:2.10-alpine AS production
41+
42+
COPY --from=builder /usr/src/app/packages/demo-app/dist /usr/share/caddy
43+
44+
WORKDIR /usr/share/caddy
45+
46+
COPY docker-command.sh /run/docker-command.sh
47+
48+
EXPOSE 80
49+
50+
CMD ["/run/docker-command.sh"]
951

10-
CMD parcel build -d /app/dist --public-url './' index.html

frontend/docker-command.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
# If CORELLE_API_URL is set in the environment, substitute it in index.html
4+
if [ -n "$CORELLE_API_URL" ]; then
5+
echo "Substituting CORELLE_API_URL in index.html"
6+
sed -i "s|window.corelleAPIBaseURL = null|window.corelleAPIBaseURL = '$CORELLE_API_URL'|g" index.html
7+
else
8+
echo "CORELLE_API_URL is not set, using default value."
9+
fi
10+
11+
# Start caddy
12+
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile

frontend/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
"scripts": {
55
"dev": "yarn workspace @corelle/demo-app run dev",
66
"build": "yarn workspaces foreach -A -p run build",
7-
"publish": "scripts/publish"
7+
"publish": "scripts/publish",
8+
"build:demo-app": "yarn workspace @corelle/demo-app run build"
89
},
910
"author": "Daven Quinn",
1011
"workspaces": [
1112
"packages/*"
1213
],
13-
"packageManager": "yarn@4.6.0",
14+
"packageManager": "yarn@4.9.4",
1415
"devDependencies": {
15-
"@parcel/packager-ts": "2.13.3",
16-
"@parcel/transformer-typescript-types": "2.13.3",
1716
"prettier": "^3.5.1",
1817
"typescript": "^5.7.3"
1918
}

frontend/packages/demo-app/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
<!DOCTYPE html>
12
<html>
23
<head>
34
<meta charset="UTF-8">
45
<title>Corelle plate rotations service</title>
6+
<link rel="stylesheet" href="./src/app.sass">
57
</head>
68
<body>
9+
<script type="text/javascript">
10+
// Script to inject environment variables at runtime
11+
window.corelleAPIBaseURL = null;
12+
</script>
713
<div id="root"></div>
814
<script type="module" src="./src/index.ts"></script>
915
</body>

frontend/packages/demo-app/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@
66
"private": true,
77
"type": "module",
88
"scripts": {
9-
"dev": "vite ."
9+
"dev": "vite .",
10+
"build": "vite build"
1011
},
1112
"author": "Daven Quinn",
1213
"license": "ISC",
1314
"devDependencies": {
1415
"sass-embedded": "^1.85.0",
15-
"stylus": "^0.54.5",
1616
"vite": "^6.1.0"
1717
},
1818
"prettier": {},
1919
"dependencies": {
2020
"@blueprintjs/core": "^5",
2121
"@corelle/svg-map-layers": "workspace:^",
2222
"@macrostrat/hyper": "^3.0.6",
23-
"@macrostrat/svg-map-components": "^1.0.2",
24-
"@macrostrat/ui-components": "^4.1.0",
25-
"d3-geo": "^3.1.1",
23+
"@macrostrat/svg-map-components": "^1.0.5",
24+
"@macrostrat/ui-components": "^4.4.6",
2625
"react": "^18",
2726
"react-dom": "^18",
2827
"react-fps-stats": "^0.3.1"

0 commit comments

Comments
 (0)