Skip to content

Commit

Permalink
fix: deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhJae committed Sep 3, 2024
1 parent c1bd0bf commit ea68163
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
git pull origin main
sudo docker stop ${{ secrets.APP_NAME }} || true
sudo docker rm ${{ secrets.APP_NAME }} || true
sudo docker system prune -f
sudo docker build -t ${{ secrets.APP_NAME }} .
sudo docker compose up -d
ENDSSH
47 changes: 31 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
ARG NODE_VERSION=22.5.1

FROM node:${NODE_VERSION}-slim AS base
# Create build stage
FROM node:${NODE_VERSION}-slim AS build

ARG PORT=3000
# Enable pnpm
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

ENV NODE_ENV=production
# Set the working directory inside the container
WORKDIR /app

# Copy package.json and pnpm-lock.yaml files to the working directory
COPY ./package.json /app/
COPY ./pnpm-lock.yaml /app/

WORKDIR /src
## Install dependencies
RUN pnpm install --shamefully-hoist

# Build
FROM base AS build
# Copy the rest of the application files to the working directory
COPY . ./

COPY --link package.json package-lock.json ./
RUN npm install --omit=dev
# Build the application
RUN pnpm run build

COPY --link . .
# Create a new stage for the production image
FROM node:${NODE_VERSION}-slim

RUN npm run build
RUN npm prune --production
# Set the working directory inside the container
WORKDIR /app

# Run
FROM base
# Copy the output from the build stage to the working directory
COPY --from=build /app/.output ./

ENV PORT=$PORT
# Define environment variables
ENV HOST=0.0.0.0 NODE_ENV=production
ENV NODE_ENV=production

COPY --from=build /src/.output /src/.output
# Expose the port the application will run on
EXPOSE 3000

CMD [ "node", ".output/server/index.mjs" ]
# Start the application
CMD ["node","/app/server/index.mjs"]

0 comments on commit ea68163

Please sign in to comment.