-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
114 lines (97 loc) · 2.85 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
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
FROM ubuntu:22.04 AS builder
ENV PYTHON_VERSION=3.12.2
ENV POETRY_VERSION=1.7.1
# make application directory
RUN mkdir -p /app
# add apl user/group
RUN groupadd -g 1000 apl \
&& useradd -g apl -s /bin/bash -u 1000 -p apl apl \
&& echo 'apl ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& chown -R apl:apl /app
# install packages
RUN apt-get update -q \
&& apt-get upgrade -qy \
&& apt-get install -y --no-install-recommends \
unzip \
build-essential \
ca-certificates \
curl \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
zlib1g-dev \
libffi-dev \
python3-dev \
libpq-dev \
automake \
pkg-config \
libtool \
libgmp-dev \
language-pack-ja-base \
language-pack-ja \
git \
libyaml-cpp-dev \
libc-bin \
liblzma-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# install pyenv
RUN git clone https://github.com/pyenv/pyenv.git /home/apl/.pyenv
RUN chown -R apl:apl /home/apl
USER apl
RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~apl/.bash_profile \
&& echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~apl/.bash_profile \
&& echo 'export POETRY_CACHE_DIR=/tmp/poetry_cache' >> ~apl/.bash_profile \
&& echo 'eval "$(pyenv init --path)"' >> ~apl/.bash_profile \
&& echo 'export LANG=ja_JP.utf8' >> ~apl/.bash_profile
# install python
RUN . ~/.bash_profile \
&& pyenv install $PYTHON_VERSION \
&& pyenv global $PYTHON_VERSION \
&& pip install --upgrade --no-cache-dir pip setuptools
# install poetry
RUN . ~/.bash_profile \
&& python -m pip install --no-cache-dir poetry==$POETRY_VERSION \
&& . ~/.bash_profile \
&& poetry config virtualenvs.create false
# install python packages
COPY --chown=apl:apl . /app/ibet-Wallet-API
RUN . ~/.bash_profile \
&& cd /app/ibet-Wallet-API \
&& poetry install --only main --no-root -E ibet-explorer \
&& rm -f /app/ibet-Wallet-API/pyproject.toml \
&& rm -f /app/ibet-Wallet-API/poetry.lock \
&& rm -rf /app/ibet-Wallet-API/tests/
FROM ubuntu:22.04 AS runner
# make application directory
RUN mkdir -p /app
# add apl user/group
RUN groupadd -g 1000 apl \
&& useradd -g apl -s /bin/bash -u 1000 -p apl apl \
&& echo 'apl ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& chown -R apl:apl /app
# install packages
RUN apt-get update -q \
&& apt-get upgrade -qy \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
libssl-dev \
libpq-dev \
language-pack-ja-base \
language-pack-ja \
jq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# copy python and dependencies from builder stage
USER apl
COPY --from=builder --chown=apl:apl /home/apl/ /home/apl/
COPY --from=builder --chown=apl:apl /app/ibet-Wallet-API/ /app/ibet-Wallet-API/
RUN . ~/.bash_profile
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app/ibet-Wallet-API
COPY run.sh healthcheck.sh /app/
EXPOSE 5000
CMD ["/app/run.sh"]
HEALTHCHECK --interval=10s CMD ["/app/healthcheck.sh"]