-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (29 loc) · 897 Bytes
/
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
# syntax=docker/dockerfile:1
FROM python:3.8-slim-buster as base
# Setup ENV variables here (if needed in the future)
FROM base as python-deps
# Install pipenv
RUN pip3 install pipenv
# Install python dependencies in /.venv
COPY Pipfile .
COPY Pipfile.lock .
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
FROM base
# install postgres driver
RUN apt update && \
apt install libpq-dev -y && \
rm -rf /var/lib/apt/lists/*
# Copy virtual env from python-deps stage
COPY --from=python-deps /.venv /.venv
ENV PATH="/.venv/bin:$PATH"
# Setup workdir and add to PYTHONPATH
WORKDIR /bot
ENV PYTHONPATH="/bot/kipubot/:$PYTHONPATH"
# Install app into container
COPY . .
# Create a non-root user and add permission to access /bot folder
RUN adduser -u 5678 --disabled-password --gecos "" botuser
RUN chown -R botuser /bot
USER botuser
# Run the app
CMD [ "python3", "-m", "kipubot" ]