Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.git
.yarn/cache
.yarn/install-state.gz
node_modules
packages/*/src
packages/*/node_modules
.yarn/*
**/dist
**/node_modules
plugins
*.local.yaml
coverage
dist-types
examples
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ jobs:
with:
fetch-depth: 0

- name: Checkout Node 18
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install
run: |
yarn install --frozen-lockfile
Expand Down
65 changes: 31 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,65 +1,62 @@
# Stage 1 - Create yarn install skeleton layer
FROM registry.access.redhat.com/ubi9/nodejs-18:latest AS packages

#WORKDIR /app
COPY package.json yarn.lock ./

COPY packages packages

# Stage 1 - Install dependencies
FROM registry.access.redhat.com/ubi9/nodejs-18:latest AS deps
USER 0

RUN chgrp -R 0 /opt/app-root/src && \
chmod -R g=u /opt/app-root/src

USER 1001

RUN npm install -g yarn && \
fix-permissions ./ && \
find packages -mindepth 2 -maxdepth 2 \! -name "package.json" -exec rm -rf {} \+
# Install yarn
RUN \
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
dnf install -y yarn

# Stage 2 - Install dependencies and build packages
FROM registry.access.redhat.com/ubi9/nodejs-18:latest AS build
COPY ./package.json ./yarn.lock ./
COPY ./packages ./packages

COPY --from=packages /opt/app-root/src .
# Remove all files except package.json
RUN find packages -mindepth 2 -maxdepth 2 \! -name "package.json" -exec rm -rf {} \+

RUN fix-permissions ./ && \
yarn install --frozen-lockfile --network-timeout 600000 && rm -rf "$(yarn cache dir)"

COPY . .
RUN yarn install --frozen-lockfile

# Stage 2 - Build packages
FROM registry.access.redhat.com/ubi9/nodejs-18:latest AS build
USER 0

RUN chgrp -R 0 /opt/app-root/src && \
chmod -R g=u /opt/app-root/src
# Install yarn
RUN \
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
dnf install -y yarn

USER 1001
COPY . .
COPY --from=deps /opt/app-root/src .

RUN yarn tsc
RUN yarn --cwd packages/backend build
RUN yarn build:backend

# Stage 3 - Build the actual backend image and install production dependencies
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:latest

FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:latest AS runner
USER 0

# Install yarn
RUN \
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
microdnf install -y yarn

# Install gzip for tar and clean up
RUN microdnf install -y gzip && microdnf clean all

# Switch to nodejs user
USER 1001

# Copy the install dependencies from the build stage and context
COPY --from=build /opt/app-root/src/yarn.lock /opt/app-root/src/package.json /opt/app-root/src/packages/backend/dist/skeleton.tar.gz ./
RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz

RUN npm install -g yarn && \
yarn install --frozen-lockfile --production --network-timeout 600000 && rm -rf "$(yarn cache dir)"
# Install production dependencies
RUN yarn install --frozen-lockfile --production && yarn cache clean

# Copy the built packages from the build stage
COPY --from=build /opt/app-root/src/packages/backend/dist/bundle.tar.gz .
RUN tar xzf bundle.tar.gz && rm bundle.tar.gz

# Copy any other files that we need at runtime
COPY app-config.yaml ./

RUN fix-permissions ./
COPY ./app-config.yaml .

CMD ["node", "packages/backend", "--config", "app-config.yaml"]