-
Notifications
You must be signed in to change notification settings - Fork 107
[WIP] Build process for frontendbase apps npm workspaces flavor (aka: the good one) #284
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
Changes from 15 commits
e39cbac
43c6e81
76af687
7a40e2d
ec75e8a
4621a8b
31fc159
6b13d73
aa55054
5a403a6
2afc49b
0bcc14d
16c4908
788f347
6c2c3da
0ccf4a1
ece781a
c88c6fa
a39733c
9580bf9
e2f903d
ac86f38
e3b3658
327d455
46fa576
7483129
0eeef3a
24d54a0
17a5a67
b52cee6
065a084
2b9a182
7c07801
972d2c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -82,6 +82,33 @@ RUN npm run build | |||||
| {{ patch("mfe-dockerfile-post-npm-build-{}".format(app_name)) }} | ||||||
| {% endfor %} | ||||||
|
|
||||||
|
|
||||||
| {%- for app_name, app in iter_frontend_sites() %} | ||||||
|
Collaborator
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.
Suggested change
|
||||||
| ######## build of site-{{ app_name }} | ||||||
| FROM base AS site-{{ app_name }}-common | ||||||
| WORKDIR /openedx/app | ||||||
|
holaontiveros marked this conversation as resolved.
Outdated
|
||||||
|
|
||||||
| {% if app.get("repository") and app["repository"] == "local" %} | ||||||
|
holaontiveros marked this conversation as resolved.
Outdated
|
||||||
| COPY frontend-site/ /openedx/app | ||||||
| {% else %} | ||||||
| RUN git clone --depth 1 --branch {{ app.get("version", MFE_COMMON_VERSION) }} {{ app["repository"] }} . | ||||||
|
holaontiveros marked this conversation as resolved.
Outdated
|
||||||
| {% endif %} | ||||||
|
|
||||||
| WORKDIR /openedx/app/packages | ||||||
| # Git clone all frontend apps that should be built | ||||||
| {% for app_name, app in iter_frontend_apps() %} | ||||||
| {% if app.get("repository") %} | ||||||
| RUN git clone --depth 1 --branch {{ app.get("version", MFE_COMMON_VERSION) }} {{ app["repository"] }} frontend-app-{{ app_name }} | ||||||
| {% endif %} | ||||||
|
Collaborator
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. As you mentioned elsewhere, we're missing the volume mounts. |
||||||
| {% endfor %} | ||||||
|
|
||||||
| WORKDIR /openedx/app | ||||||
| ARG NPM_REGISTRY={{ NPM_REGISTRY }} | ||||||
| RUN --mount=type=cache,target=/root/.npm-sites,sharing=shared npm install --no-audit --no-fund --registry=$NPM_REGISTRY | ||||||
| RUN npm run build:packages | ||||||
|
holaontiveros marked this conversation as resolved.
|
||||||
| RUN PUBLIC_PATH="/site-{{ app.get("site", "default") }}/" npm run build | ||||||
| {% endfor %} | ||||||
|
|
||||||
| ####### final production image with all static assets | ||||||
| FROM {{ MFE_CADDY_DOCKER_IMAGE }} AS production | ||||||
|
|
||||||
|
|
@@ -92,4 +119,8 @@ RUN mkdir -p /openedx/dist | |||||
| COPY --from={{ app_name }}-prod /openedx/app/dist /openedx/dist/{{ app_name }} | ||||||
| {% endfor %} | ||||||
|
|
||||||
| {% for app_name, app in iter_frontend_sites() %} | ||||||
| COPY --from=site-{{ app_name }}-common /openedx/app/dist /openedx/dist/site-{{ app_name }} | ||||||
| {% endfor %} | ||||||
|
|
||||||
| {{ patch("mfe-dockerfile-production-final") }} | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| TURBO = TURBO_TELEMETRY_DISABLED=1 turbo --dangerously-disable-package-manager-check | ||
|
|
||
| .PHONY: bin-link build-packages clean-packages clean dev-packages | ||
|
|
||
| # NPM doesn't bin-link workspace packages during install, so it must be done manually. | ||
| bin-link: | ||
| [ -f packages/frontend-base/package.json ] && npm rebuild --ignore-scripts @openedx/frontend-base || true | ||
|
|
||
| build-packages: | ||
| $(TURBO) run build | ||
| $(MAKE) bin-link | ||
|
|
||
| clean-packages: | ||
| $(TURBO) run clean | ||
|
|
||
| dev-packages: | ||
| $(TURBO) run watch:build dev:site | ||
|
|
||
| dev-site: bin-link | ||
| npm run dev | ||
|
|
||
| clean: | ||
| rm -rf dist |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| { | ||
| "name": "@openedx/frontend-template-site", | ||
| "version": "1.0.0", | ||
| "description": "Frontend site template", | ||
|
holaontiveros marked this conversation as resolved.
Outdated
|
||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/openedx/frontend-template-site.git" | ||
| }, | ||
|
holaontiveros marked this conversation as resolved.
Outdated
|
||
| "workspaces": [ | ||
| "packages/*" | ||
| ], | ||
| "browserslist": [ | ||
| "extends @edx/browserslist-config" | ||
| ], | ||
| "sideEffects": [ | ||
| "*.css", | ||
| "*.scss" | ||
| ], | ||
| "scripts": { | ||
| "build": "openedx build", | ||
| "build:packages": "make build-packages", | ||
| "clean:packages": "make clean-packages", | ||
| "dev": "PORT=8080 openedx dev", | ||
| "dev:site": "make dev-site", | ||
| "dev:packages": "make dev-packages", | ||
| "clean": "make clean", | ||
| "serve": "openedx serve" | ||
| }, | ||
| "author": "Open edX", | ||
| "license": "AGPL-3.0", | ||
| "homepage": "https://github.com/openedx/frontend-template-site#readme", | ||
| "bugs": { | ||
| "url": "https://github.com/openedx/frontend-template-site/issues" | ||
| }, | ||
| "dependencies": { | ||
| "@edx/brand": "npm:@openedx/brand-openedx@^1.2.3", | ||
|
holaontiveros marked this conversation as resolved.
Outdated
|
||
| {%- for app_name, app_attrs in iter_frontend_apps() %} | ||
| "@openedx/frontend-app-{{ app_name }}": "^1.0.0-alpha || 0.0.0-dev", | ||
|
Collaborator
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. I think the version is going to have to be configurable per app as a string property, so that it can be configured by operators. I'm also not sure what to do about |
||
| {%- endfor %} | ||
| "@openedx/frontend-base": "^1.0.0-alpha || 0.0.0-dev" | ||
|
holaontiveros marked this conversation as resolved.
Outdated
|
||
| }, | ||
| "devDependencies": { | ||
| "@edx/browserslist-config": "^1.5.0", | ||
|
holaontiveros marked this conversation as resolved.
Outdated
|
||
| "turbo": "^2.8.16" | ||
| }, | ||
| "peerDependencies": { | ||
| "@openedx/paragon": "^23", | ||
|
holaontiveros marked this conversation as resolved.
Outdated
|
||
| "@tanstack/react-query": "^5", | ||
| "react": "^18", | ||
| "react-dom": "^18", | ||
| "react-router": "^6", | ||
| "react-router-dom": "^6" | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.