-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (40 loc) · 1.76 KB
/
Dockerfile
File metadata and controls
55 lines (40 loc) · 1.76 KB
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
# Use the official Node.js 20.17.0 image as a parent image
FROM node:24
# 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 findutils -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 . .
# Create cleanup script for Chrome temp files
RUN echo '#!/bin/sh\n\
# Clean Chrome temporary files\n\
find /tmp -name ".com.google.Chrome.*" -type f -mmin +5 -delete 2>/dev/null || true\n\
find /tmp -name "puppeteer_dev_chrome_profile-*" -type d -mmin +30 -exec rm -rf {} + 2>/dev/null || true\n\
find /tmp -name "Crashpad" -type d -mmin +30 -exec rm -rf {} + 2>/dev/null || true\n\
' > /usr/local/bin/cleanup-chrome-temp.sh && chmod +x /usr/local/bin/cleanup-chrome-temp.sh
# 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
# SET FFMPEG_PATH
ENV FFMPEG_PATH=/usr/bin/ffmpeg
# 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"]