-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (44 loc) · 1.59 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
# Use the official Python image as the base image
FROM python:3.8-slim AS base
# Set the working directory inside the container
WORKDIR /app
# Install dependencies
RUN apt-get update && \
apt-get install -y wget unzip curl gnupg procps && \
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | \
gpg --dearmor -o /etc/apt/keyrings/ngrok.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/ngrok.gpg] https://ngrok-agent.s3.amazonaws.com buster main" | \
tee /etc/apt/sources.list.d/ngrok.list && \
apt-get update && \
apt-get install -y ngrok
# Set up ngrok authtoken (using the v3.x command)
ARG NGROK_AUTHTOKEN
RUN ngrok config add-authtoken $NGROK_AUTHTOKEN
# Install virtualenv to manage Python dependencies inside the container
RUN pip install virtualenv
# Create a persistent virtual environment outside the codebase directory
RUN python -m virtualenv /venv
ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Install dependencies inside the virtual environment
COPY core/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the codebase to the container
COPY . .
# Expose application and ngrok API ports
EXPOSE 5001 4040
# Test Stage
FROM base AS test
# Run unit tests with pytest
CMD ["pytest", "core/tests"]
# Production Stage
FROM base AS production
# Copy entrypoint script and set permissions
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Copy the codebase to the production stage
COPY --from=base /app /app
# Set entrypoint
ENTRYPOINT ["/app/entrypoint.sh"]
# Command to run the application
CMD ["python", "core/run.py"]