-
Notifications
You must be signed in to change notification settings - Fork 24
WIP PLATTA-7042 #1274
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
Draft
tuomas777
wants to merge
24
commits into
main
Choose a base branch
from
Platta-7042
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
WIP PLATTA-7042 #1274
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
637c293
Platta-7042-docker-file-changes
KannappanSomu 6544d3b
docker ignore
KannappanSomu 0b80c89
ignore engine
KannappanSomu 52a2368
copy scripts
KannappanSomu ddc7502
add copy instructions
KannappanSomu dbd5353
copy files
KannappanSomu 3cb4e53
change build folder
KannappanSomu d15524c
workdir for nginx
KannappanSomu c56d1aa
remove includes from base
KannappanSomu e3fc032
remoe healthz
KannappanSomu 753dd02
readiness
KannappanSomu 5b619a1
branch
KannappanSomu 092d24a
new-base-image with readiness
KannappanSomu 6837082
env variables
KannappanSomu 15c07f8
comment
KannappanSomu a9a6cd4
nodejs 22
KannappanSomu 4ca7962
remove copy step
KannappanSomu 962338a
base image env.sh
KannappanSomu ea22bcd
remove env in build stage
KannappanSomu bc86cff
rename variable
KannappanSomu 0fdb27c
port changed
KannappanSomu 5b5cacb
env.sh in readme
KannappanSomu 9749578
--ignore-scripts
KannappanSomu 91cca93
yarn update-runtime-env
KannappanSomu 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 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 |
|---|---|---|
|
|
@@ -2,4 +2,7 @@ node_modules | |
| dist | ||
| .dockerignore | ||
| Dockerfile | ||
| Dockerfile.prod | ||
| Dockerfile.prod | ||
| .git | ||
| .gitignore | ||
| *.md | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,104 +1,48 @@ | ||
| # =============================================== | ||
| FROM registry.access.redhat.com/ubi9/nodejs-22 as appbase | ||
| # =============================================== | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| USER root | ||
| RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo | ||
| RUN yum -y install yarn | ||
|
|
||
| # Official image has npm log verbosity as info. More info - https://github.com/nodejs/docker-node#verbosity | ||
| ENV NPM_CONFIG_LOGLEVEL warn | ||
|
|
||
| ARG NODE_ENV=production | ||
| ENV NODE_ENV $NODE_ENV | ||
|
|
||
| # Yarn | ||
| ENV YARN_VERSION 1.22.19 | ||
| RUN yarn policies set-version $YARN_VERSION | ||
|
|
||
| # Most files from source tree are needed at runtime | ||
| # COPY . /app/ | ||
| RUN chown -R default:root /app | ||
|
|
||
| # Install npm dependencies and build the bundle | ||
| USER default | ||
|
|
||
| COPY --chown=default:root package.json yarn.lock /app/ | ||
| COPY --chown=default:root ./scripts /app/scripts | ||
| COPY --chown=default:root ./public /app/public | ||
| COPY --chown=default:root ./cities /app/cities | ||
| COPY --chown=default:root ./assets /app/assets | ||
|
|
||
| RUN yarn config set network-timeout 300000 | ||
| RUN yarn --frozen-lockfile --ignore-scripts --network-concurrency 1 && yarn cache clean --force | ||
| RUN yarn update-runtime-env | ||
|
|
||
| COPY --chown=default:root index.html vite.config.mjs eslint.config.mjs .prettierrc .env* /app/ | ||
| COPY --chown=default:root ./src /app/src | ||
|
|
||
| # ============================= | ||
| FROM appbase as development | ||
| # ============================= | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Set NODE_ENV to development in the development container | ||
| ARG NODE_ENV=development | ||
| ENV NODE_ENV $NODE_ENV | ||
|
|
||
| # Bake package.json start command into the image | ||
| CMD yarn start | ||
|
|
||
| # =================================== | ||
| FROM appbase as staticbuilder | ||
| # =================================== | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # ============================================================ | ||
| # STAGE 1: Build the Static Assets | ||
| # ============================================================ | ||
| FROM helsinki.azurecr.io/nodejs-builder-base:1.0 AS staticbuilder | ||
|
|
||
| # 1. Install dependencies | ||
| # Base already has /app as WORKDIR | ||
| COPY --chown=default:root package.json yarn.lock ./ | ||
| COPY --chown=default:root ./scripts ./scripts | ||
| COPY --chown=default:root ./public ./public | ||
| COPY --chown=default:root ./cities ./cities | ||
| COPY --chown=default:root ./assets ./assets | ||
|
|
||
| # 2. Run the install | ||
| RUN yarn --frozen-lockfile --ignore-engines --network-concurrency 1 && yarn cache clean --force | ||
|
|
||
| # 3. Copy remaining source files | ||
| COPY --chown=default:root index.html vite.config.mjs eslint.config.mjs .prettierrc .env* ./ | ||
| COPY --chown=default:root ./src ./src | ||
|
|
||
| # 4. Perform the build | ||
| ARG REACT_APP_SENTRY_RELEASE | ||
|
|
||
| ENV REACT_APP_RELEASE=${REACT_APP_SENTRY_RELEASE:-""} | ||
|
|
||
| RUN yarn build | ||
|
|
||
| # Process nginx configuration with APP_VERSION substitution | ||
| COPY .prod/nginx.conf /app/nginx.conf.template | ||
| RUN export APP_VERSION=$(yarn --silent app:version | tr -d '\n') && \ | ||
| envsubst '${APP_VERSION},${REACT_APP_RELEASE}' < /app/nginx.conf.template > /app/nginx.conf | ||
|
|
||
| # ============================= | ||
| FROM registry.access.redhat.com/ubi9/nginx-122 as production | ||
| # ============================= | ||
|
|
||
| USER root | ||
|
|
||
| RUN chgrp -R 0 /usr/share/nginx/html && \ | ||
| chmod -R g=u /usr/share/nginx/html | ||
| # ============================================================ | ||
| # STAGE 2: Production Runtime | ||
| # ============================================================ | ||
| FROM helsinki.azurecr.io/nginx-spa-standard:1.0 AS production | ||
|
|
||
| # Copy static build | ||
| ARG REACT_APP_SENTRY_RELEASE | ||
| ENV APP_RELEASE=${REACT_APP_SENTRY_RELEASE:-""} | ||
| # 1. Copy the compiled assets | ||
| COPY --from=staticbuilder /app/build /usr/share/nginx/html | ||
|
|
||
| # Copy processed nginx config from build stage | ||
| COPY --from=staticbuilder /app/nginx.conf /etc/nginx/nginx.conf | ||
| RUN mkdir /etc/nginx/env | ||
| COPY .prod/nginx_env.conf /etc/nginx/env/ | ||
|
|
||
| # 2. Setup Runtime Env Injection | ||
| # env.sh is provided by the base image | ||
| WORKDIR /usr/share/nginx/html | ||
|
|
||
| # Copy default environment config and setup script | ||
| COPY ./scripts/env.sh . | ||
|
KannappanSomu marked this conversation as resolved.
|
||
| COPY .env . | ||
|
|
||
| # Copy package.json so env.sh can read it | ||
| # 3. Inject Versioning for the /readiness endpoint from package.json using base image | ||
| COPY package.json . | ||
|
|
||
| RUN chmod +x env.sh | ||
|
|
||
| USER 1001 | ||
|
|
||
| CMD ["/bin/bash", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""] | ||
|
|
||
| # Expose port 8086 | ||
| EXPOSE 8086 | ||
| # - env.sh (Inherited from base image at /usr/share/nginx/html/env.sh) | ||
| # - USER 1001 (Inherited from base image) | ||
| # - EXPOSE 8080 (Inherited from base image) | ||
|
KannappanSomu marked this conversation as resolved.
|
||
| # - ENTRYPOINT/CMD (Inherited from base image) | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.