-
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
1 changed file
with
5 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,21 @@ | ||
FROM node:20-slim | ||
|
||
# Create app directory and set permissions | ||
RUN mkdir -p /website /home/node/.cache/node/corepack && \ | ||
chown -R node:node /website /home/node/.cache | ||
|
||
# Switch to non-root user | ||
USER node | ||
|
||
WORKDIR /website | ||
|
||
# Set environment variables | ||
ARG NODE_ENV=development | ||
ENV NODE_ENV=${NODE_ENV} | ||
ENV BUILD_DIR=${BUILD_DIR} | ||
ENV YARN_CACHE_FOLDER=/home/node/.cache/yarn | ||
|
||
# Copy package files with correct ownership | ||
COPY --chown=node:node website/package.json website/yarn.lock ./ | ||
|
||
# Setup Yarn | ||
RUN corepack enable | ||
RUN yarn set version 4.5.1 | ||
# Copy package files | ||
COPY website/package.json website/yarn.lock ./ | ||
|
||
# Install dependencies | ||
RUN yarn install | ||
|
||
# Copy the rest of the application | ||
COPY --chown=node:node website . | ||
COPY website . | ||
|
||
# Expose port | ||
# Build the application if in production | ||
EXPOSE 3000 | ||
|
||
# Set the command | ||
CMD if [ "$NODE_ENV" = "production" ]; then \ | ||
yarn build; \ | ||
else \ | ||
yarn dev; \ | ||
fi | ||
CMD yarn dev |