-
Notifications
You must be signed in to change notification settings - Fork 49
/
Dockerfile
51 lines (36 loc) · 1.02 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
####################################
# Builder image
####################################
FROM python:3.10-slim as builder
WORKDIR /workspace
COPY . .
# Install git
RUN apt-get update && \
apt-get install -y --no-install-recommends git
# Checkout latest tagged commit
RUN git checkout \
tags/$(git describe --tags $(git rev-list --tags --max-count=1)) \
-b latest_tag
# Ensure latest pip
RUN python -m pip install --upgrade pip
# Install hatch
RUN pip install hatch
# Clean build wheel and src tarball
RUN hatch build --clean
####################################
# Final image
####################################
FROM python:3.10-slim
# Create user and cd to work dir
RUN useradd --create-home --shell /bin/bash wtfis
WORKDIR /home/wtfis
# Copy wheel file from builder image
COPY --from=builder /workspace/dist/*.whl .
# Upgrade pip, install wheel and delete wheel file
RUN python -m pip install --upgrade pip && \
pip install *.whl && \
rm -f *.whl
# Run as user
USER wtfis
# Command
CMD ["bash"]