-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
73 lines (55 loc) · 1.71 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
# base image
FROM python:3.8-slim-buster AS base
LABEL author="Meysam Azad <[email protected]>"
ARG BUILDDIR=/build
ARG WHEELDIR=/wheelhouse
ARG REQUIREMENTS=requirements.txt
ARG USER=licenseware
ARG UID=1000
ARG GID=1000
ARG HOMEDIR=/home/${USER}
ENV BUILDDIR=${BUILDDIR} \
WHEELDIR=${WHEELDIR} \
REQUIREMENTS=${REQUIREMENTS} \
USER=${USER} \
UID=${UID} \
GID=${GID} \
PATH=${HOMEDIR}/.local/bin:${PATH} \
DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1
RUN pip install -U pip && \
apt update && \
apt install -y gcc libexpat1
RUN groupadd -g ${GID} ${USER} && \
useradd -u ${UID} -g ${GID} -m ${USER}
FROM curlimages/curl AS entrypoint
ARG DUMB_INIT='https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64'
USER root
RUN curl -sSLo /usr/local/bin/dumb-init ${DUMB_INIT} && \
chmod +x /usr/local/bin/dumb-init
# fetch dependencies
FROM base AS build
COPY ${REQUIREMENTS} ${BUILDDIR}/
RUN pip wheel -r ${BUILDDIR}/${REQUIREMENTS} -w ${WHEELDIR}
# final image
FROM base AS run
ARG HOMEDIR
ARG SDKDIR=${HOMEDIR}/sdk
ARG SERVICEDIR=${HOMEDIR}/service
ARG FILE_UPLOAD_PATH=/tmp/lware
ARG PORT=5000
EXPOSE ${PORT}
VOLUME ${FILE_UPLOAD_PATH}
COPY --from=entrypoint /usr/local/bin/dumb-init /usr/local/bin/dumb-init
COPY --from=build ${BUILDDIR} ${BUILDDIR}
COPY --from=build ${WHEELDIR} ${WHEELDIR}
RUN mkdir -p ${FILE_UPLOAD_PATH} ${SERVICEDIR} && \
chown ${USER}:${USER} ${FILE_UPLOAD_PATH} ${SERVICEDIR} && \
pip install ${WHEELDIR}/* && \
rm -rf ${BUILDDIR} ${WHEELDIR}
COPY --chown=${USER} . ${SDKDIR}
RUN pip install ${SDKDIR} && \
rm -rf ${SDKDIR}
WORKDIR ${SERVICEDIR}
USER ${USER}
ENTRYPOINT [ "/usr/local/bin/dumb-init", "--" ]