-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor/SK-1217 | Update image and remove support for py 3.8 (#755)
- Loading branch information
Showing
21 changed files
with
101 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,61 @@ | ||
# Base image | ||
ARG BASE_IMG=python:3.10-slim | ||
FROM $BASE_IMG | ||
# Stage 1: Builder | ||
ARG BASE_IMG=python:3.12-slim | ||
FROM $BASE_IMG as builder | ||
|
||
ARG GRPC_HEALTH_PROBE_VERSION="" | ||
|
||
# Requirements (use MNIST Keras as default) | ||
ARG REQUIREMENTS="" | ||
|
||
WORKDIR /build | ||
|
||
# Install build dependencies | ||
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends python3-dev gcc wget \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Add FEDn and default configs | ||
COPY . /app | ||
COPY config/settings-client.yaml.template /app/config/settings-client.yaml | ||
COPY config/settings-combiner.yaml.template /app/config/settings-combiner.yaml | ||
COPY config/settings-hooks.yaml.template /app/config/settings-hooks.yaml | ||
COPY config/settings-reducer.yaml.template /app/config/settings-reducer.yaml | ||
COPY $REQUIREMENTS /app/config/requirements.txt | ||
COPY . /build | ||
COPY $REQUIREMENTS /build/requirements.txt | ||
|
||
# Install developer tools (needed for psutil) | ||
RUN apt-get update && apt-get install -y python3-dev gcc | ||
# Install dependencies | ||
RUN python -m venv /venv \ | ||
&& /venv/bin/pip install --upgrade pip \ | ||
&& /venv/bin/pip install --no-cache-dir 'setuptools>=65' \ | ||
&& /venv/bin/pip install --no-cache-dir . \ | ||
&& if [[ ! -z "$REQUIREMENTS" ]]; then \ | ||
/venv/bin/pip install --no-cache-dir -r /build/requirements.txt; \ | ||
fi \ | ||
&& rm -rf /build/requirements.txt | ||
|
||
# Install grpc health probe checker | ||
|
||
# Install grpc health probe | ||
RUN if [ ! -z "$GRPC_HEALTH_PROBE_VERSION" ]; then \ | ||
apt-get install -y wget && \ | ||
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ | ||
chmod +x /bin/grpc_health_probe && \ | ||
apt-get remove -y wget && apt autoremove -y; \ | ||
else \ | ||
echo "No grpc_health_probe version specified, skipping installation"; \ | ||
wget -qO /build/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ | ||
chmod +x /build/grpc_health_probe; \ | ||
fi | ||
|
||
# Setup working directory | ||
# Stage 2: Runtime | ||
FROM $BASE_IMG | ||
|
||
WORKDIR /app | ||
|
||
# Create FEDn app directory | ||
SHELL ["/bin/bash", "-c"] | ||
RUN mkdir -p /app \ | ||
&& mkdir -p /app/client \ | ||
&& mkdir -p /app/certs \ | ||
&& mkdir -p /app/client/package \ | ||
&& mkdir -p /app/certs \ | ||
# | ||
# Install FEDn and requirements | ||
&& python -m venv /venv \ | ||
&& /venv/bin/pip install --upgrade pip \ | ||
&& /venv/bin/pip install --no-cache-dir 'setuptools>=65' \ | ||
&& /venv/bin/pip install --no-cache-dir -e . \ | ||
&& if [[ ! -z "$REQUIREMENTS" ]]; then \ | ||
/venv/bin/pip install --no-cache-dir -r /app/config/requirements.txt; \ | ||
fi \ | ||
# | ||
# Clean up | ||
&& rm -r /app/config/requirements.txt | ||
# Copy application and venv from the builder stage | ||
COPY --from=builder /venv /venv | ||
COPY --from=builder /build /app | ||
|
||
# Use a non-root user | ||
RUN set -ex \ | ||
# Create a non-root user | ||
&& addgroup --system --gid 1001 appgroup \ | ||
&& adduser --system --uid 1001 --gid 1001 --no-create-home appuser \ | ||
# Creare application specific tmp directory, set ENV TMPDIR to /app/tmp | ||
&& mkdir -p /app/tmp \ | ||
&& chown -R appuser:appgroup /venv /app \ | ||
# Upgrade the package index and install security upgrades | ||
&& apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
USER appuser | ||
|
||
ENTRYPOINT [ "/venv/bin/fedn" ] | ||
|
||
ENTRYPOINT [ "/venv/bin/fedn" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.