-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
58 lines (45 loc) · 1.81 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
# Dockerfile to build and serve datagateway-api
# Build stage
FROM python:3.11-alpine3.17 as builder
WORKDIR /datagateway-api-build
COPY README.md poetry.lock pyproject.toml ./
COPY datagateway_api/ datagateway_api/
RUN --mount=type=cache,target=/root/.cache \
set -eux; \
\
python3 -m pip install 'poetry~=1.3.2'; \
poetry build;
# Install & run stage
FROM python:3.11-alpine3.17
WORKDIR /datagateway-api-run
COPY --from=builder /datagateway-api-build/dist/datagateway_api-*.whl /tmp/
RUN --mount=type=cache,target=/root/.cache \
set -eux; \
\
python3 -m pip install \
'gunicorn~=20.1.0' \
/tmp/datagateway_api-*.whl; \
\
# Create a symlink to the installed python module \
DATAGATEWAY_API_LOCATION="$(python3 -m pip show datagateway_api | awk '/^Location:/ { print $2 }')"; \
ln -s "$DATAGATEWAY_API_LOCATION/datagateway_api/" datagateway_api; \
\
# Create config.yaml and search_api_mapping.json from their .example files \
cp datagateway_api/config.yaml.example datagateway_api/config.yaml; \
cp datagateway_api/search_api_mapping.json.example datagateway_api/search_api_mapping.json; \
\
# Create a non-root user to run as \
addgroup -S datagateway-api; \
adduser -S -D -G datagateway-api -H -h /datagateway-api-run datagateway-api; \
\
# Change ownership of config.yaml - the entrypoint script will need to edit it \
chown datagateway-api:datagateway-api datagateway_api/config.yaml;
USER datagateway-api
ENV ICAT_URL="http://localhost"
ENV ICAT_CHECK_CERT="false"
ENV LOG_LOCATION="/dev/stdout"
COPY docker/docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
# Serve the application using gunicorn - production ready WSGI server
CMD ["gunicorn", "-b", "0.0.0.0:8000", "datagateway_api.wsgi"]
EXPOSE 8000