-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
66 lines (49 loc) · 1.64 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
FROM --platform=linux/amd64 python:3.11-slim as dev
ENV PYTHONUNBUFFERED=1 \
TZ=Europe/Oslo \
# pip:
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_DEFAULT_TIMEOUT=100 \
# poetry:
POETRY_VERSION=1.8.3 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
POETRY_HOME='/usr/local' \
# pipx:
PIPX_BIN_DIR=/opt/pipx/bin \
PIPX_HOME=/opt/pipx/home \
# venv
VIRTUAL_ENV=/venv \
PATH="/opt/pipx/bin:/venv/bin:$PATH"
RUN apt-get update && apt-get install -y \
default-jre \
&& python -m pip install --upgrade pip pipx \
&& pipx install "poetry==$POETRY_VERSION" \
&& poetry --version \
# Cleaning cache:
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
WORKDIR /project/libecalc/
COPY ./pyproject.toml ./poetry.lock ./
# Building all dependencies first to get a python environment we can use for dev
RUN python3 -m venv $VIRTUAL_ENV && poetry install --no-interaction --no-ansi --no-root
FROM dev AS build
COPY . .
RUN python3 -m venv $VIRTUAL_ENV && poetry install
WORKDIR /project/libecalc/src/
FROM dev as dist
ARG ECALC_USER=1000
ARG ECALC_GROUP=1000
ARG ECALC_VERSION=0.0.0
RUN pip install 'wheel==0.37.1'
COPY . .
RUN mkdir /dist
# Set version in pyproject.toml, needed to update nightly version. Already done by release-please otherwise.
RUN poetry version $ECALC_VERSION
# Finally build the libecalc package
RUN poetry build
RUN cp dist/*.whl /dist/
RUN chown -R $ECALC_USER:$ECALC_GROUP /dist/
USER $ECALC_USER