Skip to content
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

build: add build and deployment automation #9

Merged
merged 4 commits into from
Sep 22, 2023

Conversation

mortennordseth
Copy link
Contributor

@mortennordseth mortennordseth commented Sep 22, 2023

  • Temporary Error Page:
    I've added a temporary error page so that the application can be built without errors
  • Rename env variable:
    I've renamed the environment variable from NEXT_PUBLIC_WEBSHOP_ORG_ID to NEXT_PUBLIC_PLANNER_ORG_ID
  • Build:
    New script in the package.json file: build:all. This runs the new build.sh script that creates a standalone build for all organizations and stores it in the dist directory.
  • Docker Image:
    I've added a Dockerfile that creates a single image that can be used to serve all organizations. The new server.js file now determines the decision on which organization to run.

Note: I've tested that each organization handles the assets correctly. However, the theme is not functioning as expected. It's worth noting that this issue persists even when using yarn dev, suggesting that the current setup is not the root cause. Please let me know if you see what is missing/wrong about the theme setup so that I can test that as well 👍

@mortennordseth mortennordseth changed the title build: build: build and deployment automation Sep 22, 2023
@mortennordseth mortennordseth changed the title build: build and deployment automation build: add build and deployment automation Sep 22, 2023
@mortennordseth mortennordseth marked this pull request as ready for review September 22, 2023 06:15
Copy link
Contributor

@adriansberg adriansberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not seeing why the theme would not work. Is none of the variables in the theme being loaded?

The rest looks good. Did you figure out how we will have to handle build time environment variables?

@mortennordseth
Copy link
Contributor Author

The theme is loaded, but most often for the incorrect org. It seems that the output CSS is the same for all environments. It looks like the webpack alias configuration isn't working properly, but can't say that for sure. Also, this works in the webshop and I can't find any differences so I find it strange 🤔

To handle build-time environment variables we would have to make some adjustments. I think one solution is to add them as secrets to the repository, suffixed with the org-name. These can be passed as build-args in the common docker workflow. The Dockerfile can then look something like this:

# Build AtB
ARG BUILD_DEPENDENT_VARIABLE_ATB
ENV BUILD_DEPENDENT_VARIABLE=$BUILD_DEPENDENT_VARIABLE_ATB

yarn setup atb
yarn build
# move to dist directory etc..

# Build NFK
...

@mortennordseth mortennordseth merged commit 2e78a3a into main Sep 22, 2023
2 checks passed
@mortennordseth mortennordseth deleted the morten/build-docker branch September 22, 2023 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants