-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (45 loc) · 1.97 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
# Start from the base image
FROM node:20-alpine3.19
# Create a non-root user
RUN adduser --disabled-password --home /home/container container
# Set up Alpine repositories
RUN echo https://dl-cdn.alpinelinux.org/alpine/v3.19/main > /etc/apk/repositories && \
echo https://dl-cdn.alpinelinux.org/alpine/v3.19/community >> /etc/apk/repositories && \
echo @edge https://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
echo @edge https://dl-cdn.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories
# Install necessary packages
# RUN apk add --no-cache --update bash chromium@edge nss@edge wget
RUN apk add --no-cache --update bash wget
# Download dumb-init based on the target platform
ARG TARGETPLATFORM
RUN ["/bin/bash", "-c", "if [ \"$TARGETPLATFORM\" = \"linux/amd64\" ]; then \
wget https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64 -O /usr/local/bin/dumb-init; \
elif [ \"$TARGETPLATFORM\" = \"linux/arm64\" ]; then \
wget https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_aarch64 -O /usr/local/bin/dumb-init; \
fi"]
# Clean up and set permissions
RUN rm -rf /var/cache/apk/* /tmp/* && \
chmod +x /usr/local/bin/dumb-init
# Set the entry point to dumb-init
ENTRYPOINT ["dumb-init", "--"]
# Set the working directory
WORKDIR /home/container/orange-bot
# Copy application files
COPY --chown=container:container --chmod=777 ./docker /home/container/orange-bot
# Set environment variables
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV USER=container
ENV HOME=/home/container
#ENV CHROME_BIN=/usr/bin/chromium-browser
ENV CHROME_BIN=/dev/null
ENV STARTUP="npm run prod"
# Install Node.js dependencies
RUN npm ci
# Copy the entrypoint script and set permissions
COPY ./entrypoint.sh /entrypoint.sh
RUN chmod 777 /entrypoint.sh
RUN chmod u+s /bin/su
# Switch to the non-root user
USER container
# Set the command to run the entrypoint script
CMD ["/bin/bash", "/entrypoint.sh"]