-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
91 lines (76 loc) · 3.24 KB
/
Dockerfile
File metadata and controls
91 lines (76 loc) · 3.24 KB
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
81
82
83
84
85
86
87
88
89
90
91
ARG PYGEOAPI_VERSION=0.23.3
FROM geopython/pygeoapi:${PYGEOAPI_VERSION}
ARG VERSION=0.26
LABEL maintainer="Jürrens, Eike Hinderk <e.h.juerrens@52north.org>" \
org.opencontainers.image.authors="Jürrens, Eike Hinderk <e.h.juerrens@52north.org>" \
org.opencontainers.image.url="https://github.com/52North/pygeoapi-k8s-manager.git" \
org.opencontainers.image.vendor="52°North GmbH" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.ref.name="52north/pygeoapi-k8s-manager" \
org.opencontainers.image.title="52°North pygeoapi k8s-manager" \
org.opencontainers.image.description="Extends pygeoapi by a manager for kubernetes jobs and a process to execute any container image on a cluster"
#
# Fight OS CVEs
#
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get dist-upgrade -y \
&& apt-get clean \
&& apt autoremove -y \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /k8s-manager
LABEL org.opencontainers.image.version="${VERSION}"
COPY . .
RUN sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
uv pip install --python /venv --group docker \
&& uv build --sdist \
&& uv pip install --python /venv "dist/pygeoapi_k8s_manager-${VERSION}.tar.gz" \
&& rm -rv /k8s-manager \
&& rm -rv /root/.cache
WORKDIR /pygeoapi
ARG GIT_COMMIT=commit-undefined
LABEL org.opencontainers.image.revision="${GIT_COMMIT}"
ARG BUILD_DATE=build-date-undefined
LABEL org.opencontainers.image.created="${BUILD_DATE}"
COPY pygeoapi-config.yaml local.config.yml
# Add build info to deployed version available via pygeoapi-context-path/static/info.txt
ARG INFO_FILE=pygeoapi/static/info.txt
ARG GIT_BRANCH=branch-undefined
ARG GIT_TAG=tag-undefined
RUN touch "${INFO_FILE}" \
&& echo "Build" > "$INFO_FILE" \
&& echo "-----" >> "$INFO_FILE" \
&& echo "timestamp: $(date -u --iso-8601=seconds)" >> "$INFO_FILE" \
&& echo "git hash: $(echo $GIT_COMMIT | cut -c1-20)" >> "$INFO_FILE" \
&& echo "git branch: $GIT_BRANCH" >> "$INFO_FILE" \
&& echo "git tag: $GIT_TAG" >> "$INFO_FILE" \
&& echo "pygeoapi: $(/venv/bin/pygeoapi --version)" >> "$INFO_FILE" \
&& cat "${INFO_FILE}"
RUN sed -i '/{{ version }}/a \
\(<a title="info" id="showInfo" href="{{ config["server"]["url"] }}/static/info.txt">info</a>\)\
<script>\
document.getElementById("showInfo").addEventListener("click", function(event) {\
event.preventDefault();\
fetch("{{ config["server"]["url"] }}/static/info.txt")\
.then(response => response.text())\
.then(data => {\
alert(data);\
})\
.catch(error => {\
alert("Error loading the file: " + error);\
});\
});\
</script>' /pygeoapi/pygeoapi/templates/_base.html
RUN sed -i '/^start_gunicorn() {/a \
\
\# Update info file to log start of deployment\n\
INFO_FILE=pygeoapi/static/info.txt\n\
touch "$INFO_FILE"\n\
echo "----------" >> "$INFO_FILE"\n\
echo "Deployment" >> "$INFO_FILE"\n\
echo "----------" >> "$INFO_FILE"\n\
echo "start: $(date -u --iso-8601=seconds)" >> "$INFO_FILE"\n\
echo "API_ROOT: $API_ROOT" >> "$INFO_FILE"\n\
echo "SCRIPT_NAME: $SCRIPT_NAME" >> "$INFO_FILE"\n\
echo "TZ: $TZ" >> "$INFO_FILE"' /entrypoint.sh