forked from Codaone/DEXBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (41 loc) · 1.35 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
# Download base image Ubuntu 18.04
FROM ubuntu:18.04
# Variable arguments to populate labels
ARG USER=dexbot
# Set ENV variables
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
ENV HOME_PATH /home/$USER
ENV SRC_PATH $HOME_PATH/source
ENV PATH $HOME_PATH/.local/bin:$PATH
ENV LOCAL_DATA $HOME_PATH/.local/share
ENV CONFIG_DATA $HOME_PATH/.config
RUN set -xe ;\
apt-get update ;\
# Prepare dependencies
apt-get install -y --no-install-recommends iputils-ping gcc make libssl-dev python3-pip python3-dev python3-setuptools \
python3-async whiptail git ;\
apt-get clean ;\
rm -rf /var/lib/apt/lists/*
RUN set -xe ;\
# Create user and change workdir
groupadd -r $USER ;\
useradd -m -g $USER $USER ;\
# Configure permissions (directories must be created with proper owner before VOLUME directive)
mkdir -p $SRC_PATH $LOCAL_DATA $CONFIG_DATA ;\
chown -R $USER:$USER $HOME_PATH
# Drop priveleges
USER $USER
WORKDIR $SRC_PATH
# Install dependencies in separate stage to speed up further builds
COPY requirements.txt $SRC_PATH/
RUN python3 -m pip install --user -r requirements.txt
# Copy project files
COPY dexbot $SRC_PATH/dexbot/
COPY *.py *.cfg Makefile README.md $SRC_PATH/
# Build the project
RUN set -xe ;\
python3 setup.py build ;\
python3 setup.py install --user
WORKDIR $HOME_PATH
VOLUME ["$LOCAL_DATA", "$CONFIG_DATA"]