-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
49 lines (40 loc) · 1.28 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
# Builds the LinuxForHealth X12 API container using a multi-stage build
# build stage
FROM python:3.10-slim-buster AS builder
# the full semantic version number, used to match to the generated wheel file in dist/
ARG X12_SEM_VER
# OS library updates and build tooling
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
build-essential \
gcc
# copy source and build files
WORKDIR /tmp/lfh-x12
COPY setup.cfg .
COPY pyproject.toml .
COPY ../src src/
# build the service
RUN python -m venv /tmp/lfh-x12/venv
ENV PATH="/tmp/lfh-x12/venv/bin:$PATH"
RUN python -m pip install --upgrade pip setuptools wheel build
RUN python -m build
RUN python -m pip install dist/linuxforhealth_x12-"$X12_SEM_VER"-py3-none-any.whl[api]
# main image
FROM python:3.10-slim-buster
# container build arguments
# lfh user id and group ids
ARG LFH_USER_ID=1000
ARG LFH_GROUP_ID=1000
# create service user and group
RUN groupadd -g $LFH_GROUP_ID lfh && \
useradd -m -u $LFH_USER_ID -g lfh lfh
USER lfh
WORKDIR /home/lfh
# configure and execute application
COPY --from=builder /tmp/lfh-x12/venv ./venv
# set venv executables first in path
ENV PATH="/home/lfh/venv/bin:$PATH"
# listening address for application
ENV X12_UVICORN_HOST=0.0.0.0
EXPOSE 5000
CMD ["python", "-m", "linuxforhealth.x12.api"]