-
Notifications
You must be signed in to change notification settings - Fork 15
/
Dockerfile
68 lines (53 loc) · 2.4 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
60
61
62
63
64
65
66
67
68
ARG PYTHON_VERSION=3.8.3-alpine3.11
ARG BASE=033969152235.dkr.ecr.us-east-1.amazonaws.com/bxbase:latest
FROM ${BASE} as builder
# Assumes this repo and bxcommon repo are at equal roots
RUN apk update \
&& apk add --no-cache linux-headers gcc libtool openssl-dev libffi \
&& apk add --no-cache --virtual .build_deps build-base libffi-dev \
&& pip install --upgrade pip
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY bxgateway/requirements.txt ./bxgateway_requirements.txt
COPY bxcommon/requirements.txt ./bxcommon_requirements.txt
# most recent version of pip doesn't seem to detect manylinux wheel correctly
# orjson cannot be installed normally due to alpine linux using musl-dev
RUN echo 'manylinux2014_compatible = True' > /usr/local/lib/python3.8/_manylinux.py
RUN pip install -U pip==20.2.2
RUN pip install orjson==3.4.6
RUN pip install -U pip wheel \
&& pip install -r ./bxgateway_requirements.txt \
-r ./bxcommon_requirements.txt
FROM python:${PYTHON_VERSION}
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN addgroup -g 502 -S bxgateway \
&& adduser -u 502 -S -G bxgateway bxgateway \
&& mkdir -p /app/bxgateway/src \
&& mkdir -p /app/bxcommon/src \
&& mkdir -p /app/bxcommon-internal/src \
&& mkdir -p /app/bxextensions \
&& chown -R bxgateway:bxgateway /app/bxgateway /app/bxcommon /app/bxextensions
RUN apk update \
&& apk add --no-cache \
'su-exec>=0.2' \
tini \
bash \
gcc \
openssl-dev \
gcompat \
&& pip install --upgrade pip
COPY --from=builder /opt/venv /opt/venv
COPY bxgateway/docker-entrypoint.sh /usr/local/bin/
COPY --chown=bxgateway:bxgateway bxgateway/src /app/bxgateway/src
COPY --chown=bxgateway:bxgateway bxcommon/src /app/bxcommon/src
COPY --chown=bxgateway:bxgateway bxcommon-internal/src /app/bxcommon-internal/src
COPY --chown=bxgateway:bxgateway bxextensions/release/alpine-3.11 /app/bxextensions
RUN chmod u+s /bin/ping
COPY bxgateway/docker-scripts/bloxroute-cli /bin/bloxroute-cli
RUN chmod u+x /bin/bloxroute-cli
WORKDIR /app/bxgateway
EXPOSE 28332 9001 1801
ENV PYTHONPATH=/app/bxcommon/src/:/app/bxcommon-internal/src/:/app/bxgateway/src/:/app/bxextensions/ \
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/app/bxextensions" \
PATH="/opt/venv/bin:$PATH"
ENTRYPOINT ["/sbin/tini", "--", "/bin/sh", "/usr/local/bin/docker-entrypoint.sh"]