-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (46 loc) · 1.65 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
FROM oven/bun:debian as base
WORKDIR /usr/src/app
RUN apt update && apt install -y bash curl cron vim
# Set environment variables for NVM
ENV NVM_DIR /root/.nvm
ENV NODE_VERSION node
# Install nvm with node and npm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
# Load NVM and install Node.js
RUN . $NVM_DIR/nvm.sh && \
nvm install $NODE_VERSION && \
nvm alias default $NODE_VERSION && \
nvm use default && \
npm install -g npm
# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS dev
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile --ignore-scripts
# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --ignore-scripts --production
# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM dev AS prerelease
COPY --from=dev /temp/dev/node_modules node_modules
COPY . .
# copy production dependencies and source code into final image
FROM base AS release
COPY --from=dev /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/. .
COPY --from=prerelease /usr/src/app/package.json .
# Create log directory
RUN mkdir -p /var/log/cron
# Copy the cron job file
COPY cronjob /etc/cron.d/cronjob
# Set the correct permissions
RUN chmod 0644 /etc/cron.d/cronjob
# Apply the cron job
RUN crontab /etc/cron.d/cronjob
# Start cron in the foreground
CMD ["cron", "-f"]
# run the app
# ENTRYPOINT [ "pm2-runtime", "start", "pm2.config.cjs" ]