-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile.arm
135 lines (109 loc) · 5 KB
/
Dockerfile.arm
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Set the base image
FROM arm64v8/python:3.8-slim AS builder
# Install linux dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y gcc \
build-essential pkg-config libusb-1.0 curl git \
sudo libudev-dev libssl-dev && \
rm -rf /var/lib/apt/lists/*
# Add hummingbot user and group
RUN groupadd -g 8211 hummingbot && \
useradd -m -s /bin/bash -u 8211 -g 8211 hummingbot
# Switch to hummingbot user
USER hummingbot:hummingbot
WORKDIR /home/hummingbot
# Install miniconda
RUN curl https://repo.anaconda.com/miniconda/Miniconda3-py38_4.10.3-Linux-aarch64.sh -o ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b && \
rm ~/miniconda.sh && \
~/miniconda3/bin/conda update -n base conda -y && \
~/miniconda3/bin/conda clean -tipsy
# Dropping default ~/.bashrc because it will return if not running as interactive shell, thus not invoking PATH settings
RUN :> ~/.bashrc
# Install nvm and CeloCLI; note: nvm adds own section to ~/.bashrc
SHELL [ "/bin/bash", "-lc" ]
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash && \
export NVM_DIR="/home/hummingbot/.nvm" && \
source "/home/hummingbot/.nvm/nvm.sh" && \
nvm install 10 && \
npm install --only=production -g @celo/[email protected] && \
nvm cache clear && \
npm cache clean --force && \
rm -rf /home/hummingbot/.cache
# Copy environment only to optimize build caching, so changes in sources will not cause conda env invalidation
COPY --chown=hummingbot:hummingbot setup/environment-linux-aarch64.yml setup/
# ./install | create hummingbot environment
RUN ~/miniconda3/bin/conda env create -f setup/environment-linux-aarch64.yml && \
~/miniconda3/bin/conda clean -tipsy && \
# clear pip cache
rm -rf /home/hummingbot/.cache
# Copy remaining files
COPY --chown=hummingbot:hummingbot bin/ bin/
COPY --chown=hummingbot:hummingbot hummingbot/ hummingbot/
COPY --chown=hummingbot:hummingbot gateway/setup/ gateway/setup/
COPY --chown=hummingbot:hummingbot gateway/src/templates gateway/src/templates
COPY --chown=hummingbot:hummingbot setup.py .
COPY --chown=hummingbot:hummingbot LICENSE .
COPY --chown=hummingbot:hummingbot README.md .
COPY --chown=hummingbot:hummingbot DATA_COLLECTION.md .
# activate hummingbot env when entering the CT
RUN echo "source /home/hummingbot/miniconda3/etc/profile.d/conda.sh && conda activate $(head -1 setup/environment-linux-aarch64.yml | cut -d' ' -f2)" >> ~/.bashrc
# ./compile + cleanup build folder
RUN /home/hummingbot/miniconda3/envs/$(head -1 setup/environment-linux-aarch64.yml | cut -d' ' -f2)/bin/python3 setup.py build_ext --inplace -j 8 && \
rm -rf build/ && \
find . -type f -name "*.cpp" -delete
# Build final image using artifacts from builer
FROM arm64v8/python:3.8-slim AS release
# Dockerfile author / maintainer
LABEL maintainer="CoinAlpha, Inc. <[email protected]>"
# Build arguments
ARG BRANCH=""
ARG COMMIT=""
ARG BUILD_DATE=""
LABEL branch=${BRANCH}
LABEL commit=${COMMIT}
LABEL date=${BUILD_DATE}
# Set ENV variables
ENV COMMIT_SHA=${COMMIT}
ENV COMMIT_BRANCH=${BRANCH}
ENV BUILD_DATE=${DATE}
ENV STRATEGY=${STRATEGY}
ENV CONFIG_FILE_NAME=${CONFIG_FILE_NAME}
ENV WALLET=${WALLET}
ENV CONFIG_PASSWORD=${CONFIG_PASSWORD}
ENV INSTALLATION_TYPE=docker
# Add hummingbot user and group
RUN groupadd -g 8211 hummingbot && \
useradd -m -s /bin/bash -u 8211 -g 8211 hummingbot
# Create sym links
RUN ln -s /conf /home/hummingbot/conf && \
ln -s /logs /home/hummingbot/logs && \
ln -s /data /home/hummingbot/data && \
ln -s /pmm_scripts /home/hummingbot/pmm_scripts && \
ln -s /scripts /home/hummingbot/scripts
# Create mount points
RUN mkdir -p /conf /logs /data /pmm_scripts /scripts \
/home/hummingbot/.hummingbot-gateway/conf \
/home/hummingbot/.hummingbot-gateway/certs && \
chown -R hummingbot:hummingbot /conf /logs /data /pmm_scripts /scripts \
/home/hummingbot/.hummingbot-gateway
VOLUME /conf /logs /data /pmm_scripts /scripts \
/home/hummingbot/.hummingbot-gateway/conf \
/home/hummingbot/.hummingbot-gateway/certs
# Pre-populate pmm_scripts/ volume with default pmm_scripts
COPY --chown=hummingbot:hummingbot pmm_scripts/ pmm_scripts/
# Pre-populate scripts/ volume with default scripts
COPY --chown=hummingbot:hummingbot scripts/ scripts/
# Install packages required in runtime
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y sudo libusb-1.0 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /home/hummingbot
# Copy all build artifacts from builder image
COPY --from=builder --chown=hummingbot:hummingbot /home/ /home/
# additional configs (sudo)
COPY docker/etc /etc
# Setting bash as default shell because we have .bashrc with customized PATH (setting SHELL affects RUN, CMD and ENTRYPOINT, but not manual commands e.g. `docker run image COMMAND`!)
SHELL [ "/bin/bash", "-lc" ]
CMD /home/hummingbot/miniconda3/envs/$(head -1 setup/environment-linux-aarch64.yml | cut -d' ' -f2)/bin/python3 bin/hummingbot_quickstart.py \
--auto-set-permissions $(id -u hummingbot):$(id -g hummingbot)