Skip to content

Commit e9acefb

Browse files
authored
build(container): reduce image size (#60)
* reduce container image size * simplify the docker compose * fix the github dispatch package to be compatible with github release webhooks Signed-off-by: Aubin Lambaré <aubin.lambare@cs-soprasteria.com>
1 parent d8ac23c commit e9acefb

5 files changed

Lines changed: 22 additions & 47 deletions

File tree

.github/workflows/package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
tags: ['v*']
77
workflow_dispatch:
88
repository_dispatch:
9-
types: [eodag_release]
9+
types: [release]
1010

1111
env:
1212
REGISTRY: ghcr.io
@@ -43,7 +43,7 @@ jobs:
4343
CONTAINER_TAG=${GITHUB_REF##*/}
4444
4545
# Check if this is a release or eodag dispatch
46-
if [[ "${GITHUB_REF_TYPE}" == "tag" || ( "${GITHUB_EVENT_NAME}" == "repository_dispatch" && "${GITHUB_EVENT_CLIENT_PAYLOAD_TYPE}" == "eodag_release" ) ]]; then
46+
if [[ "${GITHUB_REF_TYPE}" == "tag" || ( "${GITHUB_EVENT_NAME}" == "repository_dispatch" && "${GITHUB_EVENT_CLIENT_PAYLOAD_TYPE}" == "release" ) ]]; then
4747
CONTAINER_TAG="${APP_VERSION}-eodag-${EODAG_VERSION}"
4848
fi
4949

Dockerfile

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
ARG PYTHON_VERSION=3.12
22

3-
FROM python:${PYTHON_VERSION}-slim AS base
3+
FROM python:${PYTHON_VERSION}-slim
44

5-
# Any python libraries that require system libraries to be installed will likely
6-
# need the following packages in order to build
7-
RUN apt-get update && \
8-
apt-get -y upgrade && \
9-
apt-get install -y build-essential git && \
10-
apt-get clean && \
11-
rm -rf /var/lib/apt/lists/*
5+
WORKDIR /app
126

13-
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
7+
COPY . /app
148

15-
FROM base AS builder
9+
RUN python -m pip install --no-cache-dir .[server,telemetry]
1610

17-
WORKDIR /app
11+
RUN adduser --disabled-password --gecos '' appuser
1812

19-
COPY . /app
13+
USER appuser
2014

21-
RUN python -m pip install .[server,telemetry]
15+
EXPOSE 8080
2216

23-
ENTRYPOINT ["/bin/bash", "-c", "python stac_fastapi/eodag/app.py"]
17+
CMD ["uvicorn", "stac_fastapi.eodag.app:app", "--host", "0.0.0.0", "--port", "8080"]

config/otelcol_config.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ processors:
2424
batch:
2525

2626
exporters:
27-
debug:
28-
verbosity: detailed
29-
# Data sources: metrics
27+
# metrics
3028
prometheus:
3129
endpoint: 0.0.0.0:8000
3230
namespace: eodag-otelcol-exporter
3331

32+
# traces
3433
otlphttp:
3534
endpoint: "http://jaeger:4318"
3635
tls:
@@ -43,12 +42,11 @@ service:
4342
traces:
4443
receivers: [otlp]
4544
processors: [batch]
46-
exporters: [debug,otlphttp]
45+
exporters: [otlphttp]
4746

4847
metrics:
49-
# receivers: [otlp, prometheus]
5048
receivers: [otlp]
5149
processors: [batch]
52-
exporters: [debug,prometheus]
50+
exporters: [prometheus]
5351

5452
extensions: [health_check, pprof, zpages]

docker-compose-otel.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

docker-compose.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1-
networks:
2-
stacapi-eodag-network:
3-
driver: bridge
4-
51
services:
62
stac_fastapi_eodag_server:
73
image: stac-fastapi-eodag:latest
84
container_name: eodag_server
95
build: .
106
ports:
11-
- "8080:8000"
12-
networks:
13-
- stacapi-eodag-network
7+
- "8080:8080"
148
depends_on:
159
- otel-collector
1610
environment:
1711
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4318/"
1812
otel-collector:
19-
image: otel/opentelemetry-collector-contrib:0.90.1
13+
image: otel/opentelemetry-collector-contrib:latest
14+
command: ["--config=/etc/otelcol-config.yml"]
2015
container_name: otel_collector
2116
restart: unless-stopped
2217
volumes:
23-
- ./config/otelcol_config.yml:/etc/otelcol-contrib/config.yaml
24-
networks:
25-
- stacapi-eodag-network
18+
- ./config/otelcol_config.yml:/etc/otelcol-config.yml
2619
ports:
2720
- "4318:4318"
2821
- "8000:8000"
22+
jaeger:
23+
image: jaegertracing/all-in-one:latest
24+
ports:
25+
- "16686:16686" # Jaeger UI

0 commit comments

Comments
 (0)