Skip to content

Commit 44b3379

Browse files
authored
Merge pull request #62 from UIUCLibrary/61-add-traefik-config
61 add traefik config
2 parents f17fd77 + 68f3289 commit 44b3379

File tree

5 files changed

+48
-8
lines changed

5 files changed

+48
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,4 @@ fabric.properties
259259

260260
# Android studio 3.1+ serialized cache file
261261
.idea/caches/build_file_checksums.ser
262+
api.cfg

Dockerfile

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ FROM python:3.11-slim AS base_image
22

33
FROM base_image AS builder
44
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
5-
--mount=type=cache,target=/var/lib/apt,sharing=locked \
6-
apt update -y && apt install --no-install-recommends -y npm
5+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
6+
apt update -y && apt install --no-install-recommends -y npm
77
COPY getmarcapi /src/getmarcapi/
88
COPY src /src/src/
99
WORKDIR /src
@@ -16,9 +16,16 @@ ARG PIP_INDEX_URL
1616
ARG PIP_EXTRA_INDEX_URL
1717
COPY pyproject.toml uv.lock README.rst README.md setup.py MANIFEST.in /src/
1818
RUN python -m pip install --disable-pip-version-check uv && \
19-
uv build --wheel --out-dir /wheels
19+
uv build --wheel --out-dir /wheels
2020

2121
FROM base_image
22+
23+
# isntall curl for heatlh checks and testing
24+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
25+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
26+
apt update -y && apt install --no-install-recommends -y curl
27+
28+
2229
COPY --from=builder /wheels/*.whl /wheels/
2330
WORKDIR /app
2431
COPY pyproject.toml uv.lock README.rst /app/
@@ -27,10 +34,10 @@ ARG UV_INDEX_URL
2734
ARG UV_CACHE_DIR=/.cache/uv
2835
ARG UV_EXTRA_INDEX_URL
2936
RUN --mount=type=cache,target=${UV_CACHE_DIR} \
30-
python -m venv uv && \
31-
./uv/bin/pip install --disable-pip-version-check uv && \
32-
./uv/bin/uv sync --group deploy --no-dev --no-editable --no-install-project --find-links=/wheels && \
33-
./uv/bin/uv pip install --find-links=/wheels --no-index getmarcapi --no-deps
37+
python -m venv uv && \
38+
./uv/bin/pip install --disable-pip-version-check uv && \
39+
./uv/bin/uv sync --group deploy --no-dev --no-editable --no-install-project --find-links=/wheels && \
40+
./uv/bin/uv pip install --find-links=/wheels --no-index getmarcapi --no-deps
3441
EXPOSE 5000
3542
COPY api.cfg /app/settings.cfg
3643
ENV GETMARCAPI_SETTINGS=/app/settings.cfg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# getmarcapi
22

3-
3+
Are you a UIUC Library employee who wnats to know how we deploy this? See https://wiki.library.illinois.edu/libraryit/Infrastructure_Management_and_Support/III._APPLICATIONS/GetMarcApi

docker-compose-traefik.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
services:
2+
getmarc:
3+
build:
4+
context: .
5+
restart: unless-stopped
6+
networks:
7+
- proxy
8+
- default
9+
healthcheck:
10+
test: ["CMD", "curl", "-f", "http://localhost:5000"]
11+
interval: 1m30s
12+
timeout: 30s
13+
retries: 5
14+
start_period: 30s
15+
labels:
16+
- "traefik.enable=true"
17+
- "traefik.docker.network=proxy"
18+
- "traefik.http.routers.getmarc-secure.rule=Host(`${FQDN}`)"
19+
- "traefik.http.routers.getmarc-secure.entrypoints=websecure"
20+
- "traefik.http.routers.getmarc-secure.tls=true"
21+
- "traefik.http.services.getmarc-secure.loadbalancer.server.port=5000"
22+
- "traefik.http.services.getmarc-secure.loadbalancer.server.scheme=http"
23+
- "traefik.http.routers.getmarc-secure.middlewares=campus-ips-whitelist@file"
24+
25+
networks:
26+
proxy:
27+
external: true

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
services:
2+
getmarc:
3+
build: .
4+
ports:
5+
- "5000:5000"

0 commit comments

Comments
 (0)