-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
15 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,8 +4,10 @@ FROM node:20-slim | |
RUN mkdir -p /website /home/node/.cache/node/corepack && \ | ||
chown -R node:node /website /home/node/.cache | ||
|
||
# Enable corepack before switching to non-root user | ||
# RUN corepack enable | ||
# Remove system yarn and enable corepack | ||
RUN rm -rf /usr/local/bin/yarn && \ | ||
corepack enable && \ | ||
corepack prepare [email protected] --activate | ||
|
||
# Switch to non-root user | ||
USER node | ||
|
@@ -22,23 +24,18 @@ ENV PATH /website/node_modules/.bin:$PATH | |
# Copy package files with correct ownership | ||
COPY --chown=node:node website/package.json website/yarn.lock ./ | ||
|
||
# Setup Yarn | ||
RUN yarn set version 4.5.1 | ||
|
||
# Install dependencies | ||
RUN yarn install | ||
|
||
RUN yarn add next | ||
# Install dependencies using Yarn 4 | ||
RUN corepack yarn install | ||
|
||
# Copy the rest of the application | ||
COPY --chown=node:node website . | ||
|
||
# Expose port | ||
EXPOSE 3000 | ||
|
||
# Set the command | ||
# Set the command using explicit yarn path | ||
CMD if [ "$NODE_ENV" = "production" ]; then \ | ||
yarn dlx next build; \ | ||
corepack yarn build; \ | ||
else \ | ||
yarn dlx next dev; \ | ||
corepack yarn dev; \ | ||
fi |