/
Dockerfile
executable file
·35 lines (25 loc) · 1.23 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
# Node.js 18.19 pre-installed on Alpine Linux 3.19 (Python 3.11.x)
FROM node:18.19.0-alpine3.19
WORKDIR /app
# Install Python utilities
RUN apk add --no-cache --update alpine-sdk wget ca-certificates musl-dev libc-dev gcc python3-dev bash linux-headers python3 py3-pip cargo
# Install pm2
RUN npm install pm2 -g
# Copy requirements.txt from build machine to WORKDIR (/app) folder (important we do this BEFORE copying the rest of the files to avoid re-running pip install on every code change)
COPY requirements.txt requirements.txt
# Create virtual environment for Python
RUN python3 -m venv /app/venv
RUN . /app/venv/bin/activate
# Install Python requirements
RUN /app/venv/bin/pip install --no-cache-dir setuptools_rust # https://github.com/docker/compose/issues/8105#issuecomment-775931324
RUN /app/venv/bin/pip install --no-cache-dir -r requirements.txt
# Make Docker /config volume for optional config file
VOLUME /config
# Make Docker /logs volume for log file
VOLUME /logs
# Copy source code from build machine to WORKDIR (/app) folder
COPY . .
# Delete unnecessary files in WORKDIR (/app) folder (not caught by .dockerignore)
RUN echo "**** removing unneeded files ****"
# Run the app
CMD [ "pm2-runtime", "start", "ecosystem.config.json"]