Skip to content

Commit fd08577

Browse files
committed
Add docker images for code-server and registry; Update mlflow image
1 parent 0e6a6ca commit fd08577

File tree

8 files changed

+921
-678
lines changed

8 files changed

+921
-678
lines changed

.github/workflows/main.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,74 @@ jobs:
117117

118118
- name: Image digest
119119
run: echo ${{ steps.docker_build.outputs.digest }}
120+
build-code-server:
121+
runs-on: ubuntu-latest
122+
steps:
123+
- name: Checkout Repo ✅
124+
uses: actions/checkout@v2
125+
126+
- name: Job preparation 🛫 # Steps that must be carried out before creating the Docker images
127+
uses: ./.github/actions/shared-build-steps
128+
with:
129+
dockerhub_user: ${{ secrets.DOCKERHUB_USER }}
130+
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
131+
runner_os: ${{ runner.os }}
132+
github_sha: ${{ github.sha }}
133+
134+
- name: Docker meta 💬 # Creating meta information such as the image tag for the Docker image
135+
id: meta
136+
uses: docker/metadata-action@v5
137+
with:
138+
images: codecentric/from-jupyter-to-production-code-server
139+
140+
- name: Build and push code-server Docker image 🔨🐳
141+
id: docker_build_code-server
142+
uses: docker/[email protected]
143+
with:
144+
context: .
145+
file: ./docker/code-server/Dockerfile
146+
tags: ${{ steps.meta.outputs.tags }}
147+
push: ${{ github.event_name != 'pull_request' }}
148+
builder: ${{ steps.buildx.outputs.name }}
149+
cache-from: type=local,src=/tmp/.buildx-cache
150+
cache-to: type=local,dest=/tmp/.buildx-cache
151+
platforms: linux/amd64,linux/arm64
152+
153+
- name: Image digest
154+
run: echo ${{ steps.docker_build.outputs.digest }}
155+
156+
build-registry:
157+
runs-on: ubuntu-latest
158+
steps:
159+
- name: Checkout Repo ✅
160+
uses: actions/checkout@v2
161+
162+
- name: Job preparation 🛫 # Steps that must be carried out before creating the Docker images
163+
uses: ./.github/actions/shared-build-steps
164+
with:
165+
dockerhub_user: ${{ secrets.DOCKERHUB_USER }}
166+
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}
167+
runner_os: ${{ runner.os }}
168+
github_sha: ${{ github.sha }}
169+
170+
- name: Docker meta 💬 # Creating meta information such as the image tag for the Docker image
171+
id: meta
172+
uses: docker/metadata-action@v5
173+
with:
174+
images: codecentric/from-jupyter-to-production-registry
175+
176+
- name: Build and push registry Docker image 🔨🐳
177+
id: docker_build_registry
178+
uses: docker/[email protected]
179+
with:
180+
context: .
181+
file: ./docker/registry/Dockerfile
182+
tags: ${{ steps.meta.outputs.tags }}
183+
push: ${{ github.event_name != 'pull_request' }}
184+
builder: ${{ steps.buildx.outputs.name }}
185+
cache-from: type=local,src=/tmp/.buildx-cache
186+
cache-to: type=local,dest=/tmp/.buildx-cache
187+
platforms: linux/amd64,linux/arm64
188+
189+
- name: Image digest
190+
run: echo ${{ steps.docker_build.outputs.digest }}

docker/code-server/Dockerfile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# Based on https://gist.githubusercontent.com/usr-ein/c42d98abca3cb4632ab0c2c6aff8c88a/raw/19dcc899f68d0b08c2c137d3fd01715b0c84bac9/Dockerfile
4+
5+
################################
6+
# PYTHON-BASE
7+
# Sets up all our shared environment variables
8+
################################
9+
FROM --platform=$TARGETPLATFORM linuxserver/code-server:latest as python-base
10+
11+
ARG TARGETPLATFORM
12+
13+
# python
14+
ENV PYTHONUNBUFFERED=1 \
15+
# prevents python creating .pyc files
16+
PYTHONDONTWRITEBYTECODE=1 \
17+
\
18+
# pip
19+
PIP_DISABLE_PIP_VERSION_CHECK=on \
20+
PIP_DEFAULT_TIMEOUT=100 \
21+
\
22+
# paths
23+
# this is where our requirements + virtual environment will live
24+
PYSETUP_PATH="/opt/pysetup" \
25+
VENV_PATH="/opt/pysetup/.venv"
26+
27+
28+
################################
29+
# BUILDER-BASE
30+
# Used to build deps + create our virtual environment
31+
################################
32+
FROM python-base as builder-base
33+
RUN apt-get update && \
34+
apt-get install -y curl bash-completion \
35+
software-properties-common \
36+
build-essential && \
37+
add-apt-repository ppa:deadsnakes/ppa && \
38+
apt-get update && \
39+
apt-get install -y python3.12 python3.12-venv python3.12-dev && \
40+
apt-get clean && \
41+
rm -rf /var/lib/apt/lists/*
42+
43+
ENV PATH="/root/.rye/bin:$PATH"
44+
ENV RYE_INSTALL_OPTION="--yes"
45+
ENV SHELL="/bin/bash"
46+
47+
48+
# Download and install rye with proper link
49+
RUN curl -sSf https://rye.astral.sh/get | bash
50+
51+
# Source rye environment
52+
RUN echo 'source $HOME/.rye/env' >> /root/.profile
53+
RUN echo 'source "$HOME/.rye/env"' >> ~/.bashrc
54+
55+
# Expose the port used by code-server
56+
EXPOSE 8443
57+
58+
RUN /app/code-server/bin/code-server --install-extension ms-python.python

docker/mlflow/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,15 @@ RUN --mount=type=cache,target=/root/.cache \
7575
FROM python-base as production
7676
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
7777

78+
COPY ./docker/mlflow/init-mlflow.sh /entrypoint.sh
79+
80+
RUN chmod +x /entrypoint.sh
81+
82+
7883
WORKDIR /ml_data
84+
EXPOSE 5000
7985
EXPOSE 5001
8086
ENV SHELL="/bin/bash"
8187

8288

83-
ENTRYPOINT ["mlflow","server","--host","0.0.0.0","--port","5001"]
89+
ENTRYPOINT ["/entrypoint.sh"]

docker/mlflow/init-mlflow.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Default values for local storage
4+
DEFAULT_BACKEND_STORE_URI="sqlite:///mlflow.db"
5+
DEFAULT_ARTIFACT_ROOT="./mlruns"
6+
MLFLOW_PORT=5001
7+
8+
# Check for the presence of environment variables and set them if provided
9+
if [ -n "$MLFLOW_DB_URI" ]; then
10+
BACKEND_STORE_URI=$MLFLOW_DB_URI
11+
else
12+
BACKEND_STORE_URI=$DEFAULT_BACKEND_STORE_URI
13+
fi
14+
15+
if [ -n "$MLFLOW_ARTIFACT_ROOT" ]; then
16+
ARTIFACT_ROOT=$MLFLOW_ARTIFACT_ROOT
17+
else
18+
ARTIFACT_ROOT=$DEFAULT_ARTIFACT_ROOT
19+
fi
20+
21+
# Run the MLflow server with the configured backend store URI and artifact root
22+
mlflow server --backend-store-uri $BACKEND_STORE_URI --default-artifact-root $ARTIFACT_ROOT --host 0.0.0.0 --port $MLFLOW_PORT

docker/registry/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# Based on https://gist.githubusercontent.com/usr-ein/c42d98abca3cb4632ab0c2c6aff8c88a/raw/19dcc899f68d0b08c2c137d3fd01715b0c84bac9/Dockerfile
4+
5+
################################
6+
# PYTHON-BASE
7+
# Sets up all our shared environment variables
8+
################################
9+
FROM --platform=$TARGETPLATFORM registry
10+
RUN apk --no-cache add apache2-utils
11+
12+
ENV SHELL="/bin/bash"
13+
COPY ./docker/registry/init-registry.sh /entrypoint.sh
14+
15+
# Make entrypoint script executable
16+
RUN chmod +x /entrypoint.sh
17+
18+
# Set entrypoint
19+
ENTRYPOINT ["/entrypoint.sh"]

docker/registry/init-registry.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
if [ ! -f /auth/htpasswd ]; then
4+
echo "Erstelle htpasswd Datei und Benutzer"
5+
mkdir /auth/htpasswd
6+
htpasswd -c -B -b /auth/htpasswd/users.htpasswd $REGISTRY_USERNAME $REGISTRY_PASSWORD
7+
fi
8+
9+
# Starte die Registry
10+
registry serve /etc/docker/registry/config.yml

0 commit comments

Comments
 (0)