-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: packages upgrade and code refactoring (#196)
- Loading branch information
Showing
156 changed files
with
4,524 additions
and
7,895 deletions.
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
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
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 |
---|---|---|
@@ -1,86 +1,80 @@ | ||
# =============================================== | ||
FROM helsinkitest/node:20-slim as appbase | ||
FROM registry.access.redhat.com/ubi9/nodejs-20 AS appbase | ||
# =============================================== | ||
|
||
# Offical image has npm log verbosity as info. More info - https://github.com/nodejs/docker-node#verbosity | ||
# Set environment | ||
ARG PORT=3000 | ||
ENV PORT $PORT | ||
|
||
WORKDIR /app | ||
|
||
# Install yarn | ||
USER root | ||
RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \ | ||
yum -y install yarn | ||
|
||
# Yarn version | ||
ENV YARN_VERSION 4.0.0 | ||
RUN yarn policies set-version ${YARN_VERSION} | ||
|
||
|
||
# Set npm log verbosity level | ||
ENV NPM_CONFIG_LOGLEVEL warn | ||
|
||
# Global npm deps in a non-root user directory | ||
# Global npm dependencies in a non-root user directory | ||
ENV NPM_CONFIG_PREFIX=/app/.npm-global | ||
ENV PATH=$PATH:/app/.npm-global/bin | ||
|
||
# Set env | ||
ARG PORT | ||
ENV PORT $PORT | ||
|
||
# Yarn | ||
ENV YARN_VERSION 1.19.1 | ||
RUN yarn policies set-version $YARN_VERSION | ||
|
||
# Use non-root user | ||
USER appuser | ||
# Set NODE_ENV to development in the development container | ||
ARG NODE_ENV=development | ||
ENV NODE_ENV $NODE_ENV | ||
|
||
# Copy package.json and package-lock.json/yarn.lock files | ||
COPY --chown=appuser:appuser package*.json *yarn* ./ | ||
# Copy package.json and yarn.lock files | ||
COPY --chown=default:root package*.json *yarn* ./ | ||
|
||
# Make scripts in dependencies available through path | ||
ENV PATH /app/node_modules/.bin:$PATH | ||
|
||
USER root | ||
|
||
# Build scripts for production stage rely on devDependencies. When | ||
# NODE_ENV is production, some of these dependencies would not be | ||
# installed. For this purpose, we are setting NODE_ENV to "develop" for | ||
# the durationo this RUN command to ensure that all dependencies are | ||
# installed. | ||
RUN export NODE_ENV=develop && \ | ||
apt-install.sh \ | ||
build-essential && \ | ||
su appuser -c "yarn && yarn cache clean --force" && \ | ||
apt-cleanup.sh build-essential | ||
|
||
USER appuser | ||
# Install dependencies including storybook addons | ||
RUN yarn && yarn cache clean | ||
|
||
# ============================= | ||
FROM appbase as development | ||
FROM appbase AS development | ||
# ============================= | ||
|
||
# Set NODE_ENV to development in the development container | ||
ARG NODE_ENV=development | ||
ENV NODE_ENV $NODE_ENV | ||
|
||
# Copy all files | ||
COPY --chown=appuser:appuser . . | ||
COPY --chown=default:root . . | ||
|
||
# Bake package.json start command into the image | ||
CMD ["yarn", "dev"] | ||
# Start command for development | ||
CMD ["yarn", "dev:no-open"] | ||
|
||
# ============================= | ||
FROM appbase as staticbuilder | ||
FROM appbase AS staticbuilder | ||
# ============================= | ||
|
||
# Set NODE_ENV to production for build | ||
ARG NODE_ENV=production | ||
ENV NODE_ENV $NODE_ENV | ||
|
||
# Copy all files | ||
COPY --chown=appuser:appuser . . | ||
# Copy all files, including .mdx stories | ||
COPY --chown=default:root . . | ||
|
||
# Build Storybook | ||
RUN yarn build-storybook --loglevel error | ||
|
||
# ============================= | ||
FROM appbase as production | ||
FROM appbase AS production | ||
# ============================= | ||
|
||
# Set NODE_ENV to production in the production container | ||
ARG NODE_ENV=production | ||
ENV NODE_ENV $NODE_ENV | ||
|
||
# Copy build folder | ||
COPY --from=staticbuilder --chown=appuser:appuser /app/storybook-static/ /app/storybook-static/ | ||
COPY --from=staticbuilder --chown=default:root /app/storybook-static/ /app/storybook-static/ | ||
|
||
# Copy server folder | ||
COPY --from=staticbuilder --chown=appuser:appuser /app/storybook-server/ /app/storybook-server/ | ||
COPY --from=staticbuilder --chown=default:root /app/storybook-server/ /app/storybook-server/ | ||
|
||
# Start server | ||
CMD ["yarn", "node", "./storybook-server/index.js"] | ||
CMD ["node", "./storybook-server/index.js"] |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
version: '3.7' | ||
services: | ||
app: | ||
container_name: react-helsinki-headless-cms | ||
|
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
Oops, something went wrong.