Skip to content
Open
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
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Do NOT ignore .git - needed in the image for version metadata
# .git
Comment on lines +1 to +2
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The comment states that .git is needed in the image for version metadata, but the actual version metadata comes from the .gitsha and .gitref files created by the GitHub workflow, not from the .git directory itself. The comment is misleading and should be updated to clarify that .git can be ignored because the workflow explicitly creates .gitsha and .gitref files.

Suggested change
# Do NOT ignore .git - needed in the image for version metadata
# .git
# Version metadata in the image comes from .gitsha and .gitref files created by the GitHub workflow,
# so the .git directory itself is not required for version metadata.

Copilot uses AI. Check for mistakes.
node_modules
**/node_modules
npm-debug.log
yarn-error.log
dist
.DS_Store
.gitignore
.vscode
.env
.env.local
logs
*.log
coverage
tests
docs
.idea
.cache
# Ignore local config backups
server/src/configs/koji_backups/**
# Keep package and source files but ignore nested node_modules
packages/*/node_modules
4 changes: 3 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 1
Comment on lines +13 to +14
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The fetch-depth: 1 parameter is redundant as it's already the default behavior for actions/checkout@v4. While not harmful, it can be removed to simplify the configuration.

Copilot uses AI. Check for mistakes.
- name: Set .gitsha
run: 'echo ${{ github.sha }} > .gitsha'
- name: Set .gitref
Expand Down
59 changes: 53 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,63 @@
# - mount areas.json to /home/node/server/src/configs/areas.json
# - Also mount every other configuration file necessary into the according directory.

FROM node:22-alpine
FROM node:22-alpine AS builder

ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin

WORKDIR /home/node
COPY package.json .
COPY yarn.lock .
RUN apk add git
RUN npm install -g yarn

# Install minimal build deps
RUN apk add --no-cache git python3 make g++

# Install yarn (node:22 includes corepack but ensure yarn v1 available)
RUN npm install -g yarn@1.22.19

# Copy package manifests first for better layer caching
COPY package.json yarn.lock ./
COPY packages ./packages
COPY server ./server
COPY public ./public
COPY ReactMap.js ./ReactMap.js
Comment on lines +23 to +26
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The copies at lines 22-26 are redundant since line 29 uses 'COPY . .' which copies everything anyway. This negates the layer caching benefit that the earlier selective copies were supposed to provide. Either remove lines 23-26 and keep only package.json and yarn.lock before the full copy, or remove line 29 entirely if all necessary files are already copied individually.

Suggested change
COPY packages ./packages
COPY server ./server
COPY public ./public
COPY ReactMap.js ./ReactMap.js

Copilot uses AI. Check for mistakes.

# Copy remaining source needed for build (excluding node_modules via .dockerignore)
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The .dockerignore file excludes 'dist' on line 7, but the runtime stage attempts to copy it from the builder stage. If the dist directory is built during the build process, this works correctly. However, if there's a pre-existing dist directory in the source, it would be excluded from the builder stage, which is the intended behavior. The comment on line 28 of the Dockerfile should clarify that dist is intentionally excluded and will be generated by 'yarn build'.

Suggested change
# Copy remaining source needed for build (excluding node_modules via .dockerignore)
# Copy remaining source needed for build; .dockerignore intentionally excludes node_modules and any pre-existing dist, which will be regenerated by 'yarn build'

Copilot uses AI. Check for mistakes.
COPY . .
RUN yarn install

# Capture git metadata for update checks in Docker builds.
RUN if [ -d .git ]; then \
git rev-parse HEAD > .gitsha; \
ref="$(git symbolic-ref -q HEAD || true)"; \
if [ -z "$ref" ]; then ref="refs/heads/main"; fi; \
printf '%s\n' "$ref" > .gitref; \
fi

# Install all deps and build
RUN yarn install --frozen-lockfile
RUN yarn build

# Reinstall only production dependencies to a clean node_modules folder
RUN rm -rf node_modules && HUSKY=0 yarn install --production --frozen-lockfile


# Final runtime image
FROM node:22-alpine AS runtime
ENV NODE_ENV=production
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH=$PATH:/home/node/.npm-global/bin
WORKDIR /home/node

# Install yarn in runtime if you need it (keeps compatibility).
RUN npm install -g yarn@1.22.19

Comment on lines +54 to +56
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

Installing yarn globally in the runtime stage may be unnecessary if the application doesn't need to run any yarn commands at runtime. Since the production dependencies are already installed in the builder stage and copied over, consider removing this installation to further reduce image size and attack surface. Only keep it if runtime yarn commands are actually required.

Suggested change
# Install yarn in runtime if you need it (keeps compatibility).
RUN npm install -g yarn@1.22.19

Copilot uses AI. Check for mistakes.
# Copy production node_modules and built assets from builder
COPY --from=builder /home/node/node_modules ./node_modules
COPY --from=builder /home/node/package.json ./package.json
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The yarn.lock file should be copied to the runtime stage along with package.json to maintain dependency version integrity. While it's not strictly necessary for runtime, it ensures that any operations involving yarn in the container use the exact same dependency versions as the builder stage.

Suggested change
COPY --from=builder /home/node/package.json ./package.json
COPY --from=builder /home/node/package.json ./package.json
COPY --from=builder /home/node/yarn.lock ./yarn.lock

Copilot uses AI. Check for mistakes.
COPY --from=builder /home/node/server ./server
COPY --from=builder /home/node/public ./public
COPY --from=builder /home/node/dist ./dist
COPY --from=builder /home/node/ReactMap.js ./ReactMap.js
COPY --from=builder /home/node/packages ./packages
COPY --from=builder /home/node/config ./config
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

The .gitsha and .gitref files created by the GitHub workflow (lines 15-18 in docker.yml) are not explicitly copied to the runtime stage. These files are needed by server/src/services/checkForUpdates.js to determine the current version when running in Docker. Add these files to the runtime stage copy operations.

Suggested change
COPY --from=builder /home/node/config ./config
COPY --from=builder /home/node/config ./config
COPY --from=builder /home/node/.gitsha ./.gitsha
COPY --from=builder /home/node/.gitref ./.gitref

Copilot uses AI. Check for mistakes.
COPY --from=builder /home/node/.gitsha ./.gitsha
COPY --from=builder /home/node/.gitref ./.gitref
Loading