-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
80 lines (71 loc) · 2.25 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
## Base dependencies ########################################################################
ARG GO_VERSION=1.20
ARG PROTOBUF_VERSION=3.15.8
FROM golang:${GO_VERSION} as base
ARG PROTOBUF_VERSION
# This image is only for building, so we run as root
WORKDIR /src
COPY requirements_test.txt /src/requirements_test.txt
RUN true && \
apt-get update -y && \
apt-get install make git -y && \
apt-get clean autoclean && \
apt-get autoremove --yes && \
apt-get install -y \
unzip \
python3.11 \
python3-pip \
python3-venv && \
apt-get upgrade -y && \
true
# Follow PEP 668 - Marking Python base environments as “externally managed”.
RUN true && \
python3 -m venv .venv && \
. .venv/bin/activate && \
pip install pip --upgrade && \
pip install twine pre-commit && \
pip3 install -r /src/requirements_test.txt && \
true
# Install protoc
RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
RUN unzip protoc-3.15.8-linux-x86_64.zip -d /protoc
ENV PATH=${PATH}:/protoc/bin
## Test ########################################################################
FROM base as test
# Run unit tests
COPY . /src
RUN true && \
. .venv/bin/activate && \
./scripts/run_tests.sh && \
RELEASE_DRY_RUN=true RELEASE_VERSION=0.0.0 \
./scripts/publish.sh && \
./scripts/fmt.sh && \
true
## Release #####################################################################
#
# This phase builds the release and publishes it to pypi
##
FROM test as release
ARG PYPI_TOKEN
ARG RELEASE_VERSION
ARG RELEASE_DRY_RUN
RUN true && \
. .venv/bin/activate && \
./scripts/publish.sh && \
true
## Release Test ################################################################
#
# This phase installs the indicated version from PyPi and runs the unit tests
# against the installed version.
##
FROM base as release_test
ARG RELEASE_VERSION
ARG RELEASE_DRY_RUN
COPY ./tests /src/tests
COPY ./scripts/run_tests.sh /src/scripts/run_tests.sh
COPY ./scripts/install_release.sh /src/scripts/install_release.sh
RUN true && \
. .venv/bin/activate && \
./scripts/install_release.sh && \
./scripts/run_tests.sh && \
true