Compare commits
20
Commits
189a3c4e0c
...
1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e8ebce721 | ||
|
|
756a781524 | ||
|
|
0ffe89a881 | ||
|
|
5287ca66a1 | ||
|
|
cb63016421 | ||
|
|
43802259ed | ||
|
|
c8046eb98f | ||
|
|
57d1335fba | ||
|
|
ea7ee88ce1 | ||
|
|
a20c7e2c59 | ||
|
|
6945db40e1 | ||
|
|
1d8cfbfc07 | ||
|
|
74da180a07 | ||
|
|
0aa9488627 | ||
|
|
2782d6d43d | ||
|
|
82cf6bf7e6 | ||
|
|
7662463c7d | ||
|
|
9ee2fd2837 | ||
|
|
2fef740a5f | ||
|
|
7abb8db1e4 |
@@ -2,72 +2,77 @@ name: Build and Push Docker Images
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- 'images/base/**'
|
|
||||||
- 'images/jupyter/**'
|
|
||||||
tags:
|
tags:
|
||||||
- 'v*.*.*'
|
- '*.*.*'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: registry.bouvais.lu
|
REGISTRY: registry.bouvais.lu
|
||||||
BASE_IMAGE_NAME: something/base
|
BASE_IMAGE_NAME: tenant/base
|
||||||
JUPYTER_IMAGE_NAME: something/jupyter
|
JUPYTER_IMAGE_NAME: tenant/jupyter
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@v3
|
run: |
|
||||||
with:
|
docker login ${{ env.REGISTRY }} \
|
||||||
registry: ${{ env.REGISTRY }}
|
--username adrien \
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
--password "${{ secrets.DOCKER_PASSWORD }}"
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
|
|
||||||
# --- 1. BUILD BASE IMAGE ---
|
# --- 1. BUILD & TEST BASE IMAGE ---
|
||||||
- name: Extract metadata for Base
|
- name: Build Base image
|
||||||
id: meta-base
|
run: |
|
||||||
uses: docker/metadata-action@v5
|
docker build \
|
||||||
with:
|
-f ./images/base/dockerfile \
|
||||||
images: ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}
|
-t ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} \
|
||||||
tags: |
|
./images/base
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
type=ref,event=branch
|
|
||||||
type=sha,format=short
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
|
|
||||||
- name: Build and push Base image
|
- name: Test Base image
|
||||||
uses: docker/build-push-action@v5
|
run: |
|
||||||
with:
|
cid=$(docker create -u root -w /tests ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} sleep 60)
|
||||||
context: ./images/base
|
docker start "$cid"
|
||||||
# Note: Linux is case-sensitive. If your file is literally lowercase "dockerfile", change this to "dockerfile"
|
docker cp ${{ github.workspace }}/tests/. "$cid":/tests
|
||||||
file: ./images/base/Dockerfile
|
docker exec "$cid" python3 /tests/base.py
|
||||||
push: true
|
docker rm -f "$cid"
|
||||||
tags: ${{ steps.meta-base.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta-base.outputs.labels }}
|
|
||||||
|
|
||||||
# --- 2. BUILD JUPYTER IMAGE ---
|
- name: Tag Base image as latest
|
||||||
- name: Extract metadata for Jupyter
|
run: |
|
||||||
id: meta-jupyter
|
docker tag ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} \
|
||||||
uses: docker/metadata-action@v5
|
${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:latest
|
||||||
with:
|
|
||||||
images: ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}
|
|
||||||
tags: |
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
type=ref,event=branch
|
|
||||||
type=sha,format=short
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
|
|
||||||
- name: Build and push Jupyter image
|
- name: Push Base image
|
||||||
uses: docker/build-push-action@v5
|
run: |
|
||||||
with:
|
docker push ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }}
|
||||||
context: ./images/jupyter
|
docker push ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:latest
|
||||||
file: ./images/jupyter/Dockerfile
|
|
||||||
push: true
|
# --- 2. BUILD & TEST JUPYTER IMAGE ---
|
||||||
tags: ${{ steps.meta-jupyter.outputs.tags }}
|
- name: Build Jupyter image
|
||||||
labels: ${{ steps.meta-jupyter.outputs.labels }}
|
run: |
|
||||||
|
docker build \
|
||||||
|
-f ./images/jupyter/dockerfile \
|
||||||
|
--build-arg BASE_IMAGE=${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} \
|
||||||
|
-t ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:${{ github.ref_name }} \
|
||||||
|
./images/jupyter
|
||||||
|
|
||||||
|
- name: Test Jupyter dependencies
|
||||||
|
run: |
|
||||||
|
cid=$(docker create -w /tests ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:${{ github.ref_name }} sleep 60)
|
||||||
|
docker start "$cid"
|
||||||
|
docker cp ${{ github.workspace }}/tests/. "$cid":/tests
|
||||||
|
docker exec "$cid" python3 /tests/dependencies.py
|
||||||
|
docker rm -f "$cid"
|
||||||
|
|
||||||
|
- name: Tag Jupyter image as latest
|
||||||
|
run: |
|
||||||
|
docker tag ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:${{ github.ref_name }} \
|
||||||
|
${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:latest
|
||||||
|
|
||||||
|
- name: Push Jupyter image
|
||||||
|
run: |
|
||||||
|
docker push ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:${{ github.ref_name }}
|
||||||
|
docker push ${{ env.REGISTRY }}/${{ env.JUPYTER_IMAGE_NAME }}:latest
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ metadata:
|
|||||||
namespace: argocd
|
namespace: argocd
|
||||||
spec:
|
spec:
|
||||||
goTemplate: true
|
goTemplate: true
|
||||||
|
goTemplateOptions: ["missingkey=error"]
|
||||||
generators:
|
generators:
|
||||||
- git:
|
- git:
|
||||||
repoURL: https://git.bouvais.lu/adrien/ctie-exercice
|
repoURL: https://git.bouvais.lu/adrien/ctie-exercice
|
||||||
@@ -13,7 +14,7 @@ spec:
|
|||||||
- path: "tenants/*/config.yaml"
|
- path: "tenants/*/config.yaml"
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
name: 'tenant-{{.name}}'
|
name: 'tenant-{{ trimPrefix "tenant-" .path.basename }}'
|
||||||
spec:
|
spec:
|
||||||
project: tenants
|
project: tenants
|
||||||
sources:
|
sources:
|
||||||
@@ -22,13 +23,16 @@ spec:
|
|||||||
path: charts/tenant
|
path: charts/tenant
|
||||||
helm:
|
helm:
|
||||||
valueFiles:
|
valueFiles:
|
||||||
- '$values/tenants/tenant-{{.name}}/config.yaml'
|
- '$values/{{.path.path}}/config.yaml'
|
||||||
|
parameters:
|
||||||
|
- name: name
|
||||||
|
value: '{{ trimPrefix "tenant-" .path.basename }}'
|
||||||
- repoURL: https://git.bouvais.lu/adrien/ctie-exercice
|
- repoURL: https://git.bouvais.lu/adrien/ctie-exercice
|
||||||
targetRevision: main
|
targetRevision: main
|
||||||
ref: values
|
ref: values
|
||||||
destination:
|
destination:
|
||||||
server: https://kubernetes.default.svc
|
server: https://kubernetes.default.svc
|
||||||
namespace: 'tenant-{{.name}}'
|
namespace: 'tenant-{{ trimPrefix "tenant-" .path.basename }}'
|
||||||
syncPolicy:
|
syncPolicy:
|
||||||
automated:
|
automated:
|
||||||
prune: true
|
prune: true
|
||||||
|
|||||||
@@ -1,17 +1,11 @@
|
|||||||
FROM python:3.12-slim-bookworm AS base
|
FROM python:3.12-slim-bookworm AS base
|
||||||
|
|
||||||
LABEL org.opencontainers.image.title="tenant-base" \
|
|
||||||
org.opencontainers.image.description="Hardened base image for tenant workspaces" \
|
|
||||||
org.opencontainers.image.source="https://git.bouvais.lu/adrien/"
|
|
||||||
|
|
||||||
# System deps only — keep this layer stable so it's rarely rebuilt
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
tini \
|
tini \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Non-root user, fixed UID/GID for predictable K8s securityContext
|
|
||||||
RUN groupadd --gid 1000 appuser \
|
RUN groupadd --gid 1000 appuser \
|
||||||
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser
|
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser
|
||||||
|
|
||||||
@@ -19,4 +13,3 @@ WORKDIR /home/appuser
|
|||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
ENTRYPOINT ["tini", "--"]
|
ENTRYPOINT ["tini", "--"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,15 @@
|
|||||||
ARG BASE_IMAGE=registry.bouvais.lu/tenant-base:1.0.0
|
ARG BASE_IMAGE
|
||||||
FROM ${BASE_IMAGE}
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
LABEL org.opencontainers.image.title="tenant-jupyter" \
|
|
||||||
org.opencontainers.image.description="JupyterLab image built on tenant-base" \
|
|
||||||
org.opencontainers.image.base.name="${BASE_IMAGE}"
|
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
|
COPY --chown=appuser:appuser test_buckets.py /home/appuser/work/test_buckets.py
|
||||||
COPY --chown=appuser:appuser requirements.txt /tmp/requirements.txt
|
COPY --chown=appuser:appuser requirements.txt /tmp/requirements.txt
|
||||||
RUN pip install --no-cache-dir -r /tmp/requirements.txt \
|
RUN pip install --no-cache-dir -r /tmp/requirements.txt \
|
||||||
&& rm /tmp/requirements.txt
|
&& rm /tmp/requirements.txt
|
||||||
|
|
||||||
# No secrets baked in — S3 creds come from a mounted K8s Secret / env at runtime
|
|
||||||
USER appuser
|
USER appuser
|
||||||
WORKDIR /home/appuser/work
|
WORKDIR /home/appuser/work
|
||||||
|
|
||||||
COPY --chown=appuser:appuser test_script.py /home/appuser/test_script.py
|
|
||||||
|
|
||||||
EXPOSE 8888
|
EXPOSE 8888
|
||||||
|
|
||||||
CMD ["jupyter", "lab", \
|
CMD ["jupyter", "lab", \
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
name: "a" # TODO: Remove this and use path instead
|
|
||||||
|
|
||||||
image:
|
image:
|
||||||
repository: registry.bouvais.lu/tenant-jupyter
|
repository: registry.bouvais.lu/tenant/jupyter
|
||||||
tag: "1.0.0"
|
tag: "1.0.1"
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
@@ -12,8 +10,3 @@ resources:
|
|||||||
cpu: "1"
|
cpu: "1"
|
||||||
memory: 2Gi
|
memory: 2Gi
|
||||||
|
|
||||||
gpu:
|
|
||||||
enabled: true
|
|
||||||
type: "t4" # one of: none | t4 | a100 | l4
|
|
||||||
count: 1
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
image:
|
||||||
|
repository: registry.bouvais.lu/tenant/jupyter
|
||||||
|
tag: "1.0.1"
|
||||||
|
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 250m
|
||||||
|
memory: 512Mi
|
||||||
|
limits:
|
||||||
|
cpu: "1"
|
||||||
|
memory: 2Gi
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
print("SUCCESS: Python works.")
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import os
|
||||||
|
import boto3
|
||||||
|
print("SUCCESS: Import works.")
|
||||||
Reference in New Issue
Block a user