-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
44 lines (31 loc) · 1.24 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
# Use the official Node.js 20.17.0 image as a parent image
FROM node:20.17.0
# Set the working directory in the container
WORKDIR /usr/src/app
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
RUN apt-get update && apt-get install curl gnupg ffmpeg -y \
&& curl --location --silent 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 google-chrome-stable -y --no-install-recommends \
&& apt-get install -y libvips-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy package.json and package-lock.json (if available)
COPY package*.json ./
# Install dependencies
RUN npm install --os=linux --cpu=x64 sharp
# Copy the rest of your app's source code
COPY . .
# Expose the port your app runs on
EXPOSE 3000
# Set environment variables
ENV HOST=0.0.0.0
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome-stable
# Create a non-root user
RUN useradd -m appuser
# Change ownership of the working directory to the non-root user
RUN chown -R appuser:appuser /usr/src/app
# Switch to the non-root user
USER appuser
# Start the application
CMD ["node", "app/server.js"]