Skip to content

Commit

Permalink
Fix in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ternaus committed Nov 15, 2024
1 parent d5ee1dc commit c13d621
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions website/Dockerfile
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

0 comments on commit c13d621

Please sign in to comment.