Skip to content

Commit

Permalink
fix: added port to CMD start run
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseKoldewijn committed Aug 15, 2023
1 parent 84c53f2 commit f5f3bd4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# ? Build stage
FROM node:lts-slim as Builder

# Get environment variable for app port with fallback to 3000
ARG PORT=3000
ARG VERCEL_URL="http://localhost:3000"
ARG DATABASE_HOST="localhost"
ARG DATABASE_USERNAME="root"
ARG DATABASE_PASSWORD="root"

# Set environment variable for app port
ENV PORT=$PORT
ENV VERCEL_URL=$VERCEL_URL
ENV DATABASE_HOST=$DATABASE_HOST
ENV DATABASE_USERNAME=$DATABASE_USERNAME
ENV DATABASE_PASSWORD=$DATABASE_PASSWORD

# Set working directory
WORKDIR /app

Expand All @@ -20,16 +34,18 @@ RUN pnpm install
COPY . .

# Build app
RUN NODE_ENV="production" pnpm build
RUN pnpm build

# ? Production Stage
FROM node:lts-slim as Runner

# Get environment variable for app port with fallback to 3000
ARG PORT=3000
ARG NODE_ENV=production

# Set environment variable for app port
ENV PORT=$PORT
ENV NODE_ENV=$NODE_ENV

# Set working directory
WORKDIR /app
Expand All @@ -56,5 +72,5 @@ COPY --from=Builder /app/.next ./.next
EXPOSE $PORT

# Run app
CMD ["pnpm", "start"]
CMD ["pnpm", "start", "-p $PORT"]

1 comment on commit f5f3bd4

@vercel
Copy link

@vercel vercel bot commented on f5f3bd4 Aug 15, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.