-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
110 lines (84 loc) · 3.2 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
##############################################
#### FISRT STAGE: BUILD THE APPLICATION ######
##############################################
# Use the official Node.js 20 image as a base
# FROM node:20.8.0 AS build
FROM node:22.1.0-bookworm-slim AS build
# Environment variables
ARG DATABASE_URL
ENV YARN_VERSION 4.2.1
# Install necessary dependencies for Prisma
RUN apt-get update -y && \
apt-get install -y openssl
# Set working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
COPY yarn.lock ./
# Copy yarnrc file
COPY .yarnrc.yml ./
# Yarn - Install corepack
# RUN npm install -g [email protected]
# RUN corepack enable && corepack prepare yarn@stable --activate && yarn set version 4.2.1
RUN yarn policies set-version $YARN_VERSION
RUN corepack enable
# Install dependencies, including 'puppeteer'
RUN yarn install --check-cache
# Copy the rest of your application's code into the container
COPY . .
# Prisma
# COPY --from=deps /app/node_modules ./node_modules
# COPY src/database/schema.prisma ./prisma/
# RUN npx prisma generate
# Build project
RUN yarn run build
##############################################
#### SECOND STAGE: RUN THE APPLICATION #######
##############################################
# Use the official Node.js 20 image as a base
# FROM node:20.8.0
FROM node:22.1.0-bookworm-slim AS production
# Set environment variables to optimize the container
ENV NODE_ENV production
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_EXECUTABLE_PATH "/usr/bin/google-chrome-stable"
ENV YARN_VERSION 4.2.1
# Install necessary dependencies for Puppeteer's Chrome
# These dependencies are required to run Puppeteer/Chrome in a headless environment
RUN apt-get update && \
apt-get install -y wget gnupg2 ca-certificates apt-transport-https software-properties-common && \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
apt-get update && \
apt-get install -y google-chrome-stable fonts-hosny-amiri --no-install-recommends && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean
# Install necessary dependencies for Prisma
RUN apt-get update -y && \
apt-get install -y openssl
# Set working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
COPY yarn.lock ./
# Copy yarnrc file
COPY .yarnrc.yml ./
# Copy the rest of your application's code into the container
COPY --from=build /app/build ./build
# Copy static files
COPY static ./static
# Yarn - Install corepack
# RUN npm install -g [email protected]
# RUN corepack enable && corepack prepare yarn@stable --activate && yarn set version 4.2.1
RUN yarn policies set-version $YARN_VERSION
RUN corepack enable
# Install dependencies, including 'puppeteer'
RUN yarn install --check-cache
# Prisma
# COPY prisma ./prisma
COPY --from=build /app/node_modules/.prisma/client ./node_modules/.prisma/client
# Expose the port your app runs on
EXPOSE 3000
EXPOSE 7700
# Specify the command to run your app
CMD ["yarn", "run", "start"]