Skip to content

Commit

Permalink
Fixed Dockerfile and use multistage
Browse files Browse the repository at this point in the history
  • Loading branch information
renekann committed Jun 1, 2023
1 parent 6223c4b commit 651c3fc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
29 changes: 21 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
# Use official node image as the base image
FROM node:16
# First stage: Build
FROM node:16-alpine AS build

# Set /usr/src/app as the working directory
WORKDIR /usr/src/app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install Yarn
RUN apk add --no-cache yarn

# Copy package.json and yarn.lock to the working directory
COPY package.json yarn.lock ./

# Install dependencies
RUN npm install
RUN yarn install

# Copy the rest of your app's source code to the working directory
COPY . .

# TypeScript
RUN npm install typescript -g
RUN yarn global add typescript
RUN tsc

# Second stage: Run
FROM node:16-alpine

WORKDIR /usr/src/app

# Install Yarn
RUN apk add --no-cache yarn

# Copy from build stage
COPY --from=build /usr/src/app .

# Expose the port the app runs on
EXPOSE 3000

# Start the application
CMD [ "node", "dist/index.js" ]
CMD [ "yarn", "start" ]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doctolib-appointment-finder",
"version": "1.0.2",
"version": "1.0.3",
"dependencies": {
"@types/node": "^20.2.5",
"@types/node-cron": "^3.0.7",
Expand Down

0 comments on commit 651c3fc

Please sign in to comment.