-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
68 lines (55 loc) · 2.1 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
FROM openjdk:11.0.8-jre-buster as app-builder
WORKDIR /build/
COPY . /build/
RUN /build/generate.sh
FROM python:3.10-alpine3.13 as python-builder
COPY requirements.txt .
RUN export BUILD_PREREQS="gcc musl-dev libffi-dev openssl-dev postgresql-dev cargo" \
&& apk add --no-cache $BUILD_PREREQS \
&& pip3 install --no-cache-dir wheel \
&& pip3 install --user --no-warn-script-location -r requirements.txt
FROM python:3.10.2-alpine3.15
ARG HELM_VERSION=3.5.3
ARG KUBECTL_VERSION=1.20.4
ARG PYTHON_LIB_VERSION=3.10
ENV BASE_URL=https://get.helm.sh
ENV TAR_FILE=helm-v${HELM_VERSION}-linux-amd64.tar.gz
# install system-packages
RUN export PACKAGES="git bash openssh-client libpq" \
&& apk add --no-cache $PACKAGES
# copy python packages
COPY --from=python-builder /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH
ENV PYTHONPATH=/root/.local/lib/python${PYTHON_LIB_VERSION}/site-packages
# install kubectl
RUN apk add --update --no-cache curl \
&& curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl \
&& mv kubectl /usr/bin/kubectl \
&& chmod +x /usr/bin/kubectl \
&& apk del curl \
&& rm -f /var/cache/apk/*
# install helm
RUN apk add --update --no-cache curl ca-certificates bash git \
&& curl -L ${BASE_URL}/${TAR_FILE} |tar xvz \
&& mv linux-amd64/helm /usr/bin/helm \
&& chmod +x /usr/bin/helm \
&& rm -rf linux-amd64 \
&& apk del curl \
&& rm -f /var/cache/apk/*
# install ansible roles and collections
COPY requirements.yml .
RUN ansible-galaxy install -r requirements.yml \
&& rm requirements.yml
# temporary fix for pre release opera
RUN pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ opera==0.6.9.dev2
# grant access to all users for root bin and lib
RUN chmod 755 /root
RUN chmod 755 $PYTHONPATH
ENV XOPERA_API_WORKDIR=/app/.xopera-api
ENV ANSIBLE_ROLES_PATH=/root/.ansible/roles:$ANSIBLE_ROLES_PATH
# copy app code
COPY --from=app-builder /build/src/ /app/
COPY openapi-spec.yml /app/
WORKDIR /app
ENTRYPOINT ["python3"]
CMD ["-m", "opera.api.cli"]