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:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'images/base/**'
|
||||
- 'images/jupyter/**'
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
- '*.*.*'
|
||||
|
||||
env:
|
||||
REGISTRY: registry.bouvais.lu
|
||||
BASE_IMAGE_NAME: something/base
|
||||
JUPYTER_IMAGE_NAME: something/jupyter
|
||||
BASE_IMAGE_NAME: tenant/base
|
||||
JUPYTER_IMAGE_NAME: tenant/jupyter
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
run: |
|
||||
docker login ${{ env.REGISTRY }} \
|
||||
--username adrien \
|
||||
--password "${{ secrets.DOCKER_PASSWORD }}"
|
||||
|
||||
# --- 1. BUILD BASE IMAGE ---
|
||||
- name: Extract metadata for Base
|
||||
id: meta-base
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=ref,event=branch
|
||||
type=sha,format=short
|
||||
type=semver,pattern={{version}}
|
||||
# --- 1. BUILD & TEST BASE IMAGE ---
|
||||
- name: Build Base image
|
||||
run: |
|
||||
docker build \
|
||||
-f ./images/base/dockerfile \
|
||||
-t ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} \
|
||||
./images/base
|
||||
|
||||
- name: Build and push Base image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./images/base
|
||||
# Note: Linux is case-sensitive. If your file is literally lowercase "dockerfile", change this to "dockerfile"
|
||||
file: ./images/base/Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta-base.outputs.tags }}
|
||||
labels: ${{ steps.meta-base.outputs.labels }}
|
||||
- name: Test Base image
|
||||
run: |
|
||||
cid=$(docker create -u root -w /tests ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} sleep 60)
|
||||
docker start "$cid"
|
||||
docker cp ${{ github.workspace }}/tests/. "$cid":/tests
|
||||
docker exec "$cid" python3 /tests/base.py
|
||||
docker rm -f "$cid"
|
||||
|
||||
# --- 2. BUILD JUPYTER IMAGE ---
|
||||
- name: Extract metadata for Jupyter
|
||||
id: meta-jupyter
|
||||
uses: docker/metadata-action@v5
|
||||
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: Tag Base image as latest
|
||||
run: |
|
||||
docker tag ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }} \
|
||||
${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:latest
|
||||
|
||||
- name: Build and push Jupyter image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./images/jupyter
|
||||
file: ./images/jupyter/Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta-jupyter.outputs.tags }}
|
||||
labels: ${{ steps.meta-jupyter.outputs.labels }}
|
||||
- name: Push Base image
|
||||
run: |
|
||||
docker push ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:${{ github.ref_name }}
|
||||
docker push ${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:latest
|
||||
|
||||
# --- 2. BUILD & TEST JUPYTER IMAGE ---
|
||||
- name: Build Jupyter image
|
||||
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
|
||||
spec:
|
||||
goTemplate: true
|
||||
goTemplateOptions: ["missingkey=error"]
|
||||
generators:
|
||||
- git:
|
||||
repoURL: https://git.bouvais.lu/adrien/ctie-exercice
|
||||
@@ -13,7 +14,7 @@ spec:
|
||||
- path: "tenants/*/config.yaml"
|
||||
template:
|
||||
metadata:
|
||||
name: 'tenant-{{.name}}'
|
||||
name: 'tenant-{{ trimPrefix "tenant-" .path.basename }}'
|
||||
spec:
|
||||
project: tenants
|
||||
sources:
|
||||
@@ -22,13 +23,16 @@ spec:
|
||||
path: charts/tenant
|
||||
helm:
|
||||
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
|
||||
targetRevision: main
|
||||
ref: values
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: 'tenant-{{.name}}'
|
||||
namespace: 'tenant-{{ trimPrefix "tenant-" .path.basename }}'
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
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 \
|
||||
ca-certificates \
|
||||
curl \
|
||||
tini \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Non-root user, fixed UID/GID for predictable K8s securityContext
|
||||
RUN groupadd --gid 1000 appuser \
|
||||
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser
|
||||
|
||||
@@ -19,4 +13,3 @@ WORKDIR /home/appuser
|
||||
USER appuser
|
||||
|
||||
ENTRYPOINT ["tini", "--"]
|
||||
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
ARG BASE_IMAGE=registry.bouvais.lu/tenant-base:1.0.0
|
||||
ARG 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
|
||||
COPY --chown=appuser:appuser test_buckets.py /home/appuser/work/test_buckets.py
|
||||
COPY --chown=appuser:appuser requirements.txt /tmp/requirements.txt
|
||||
RUN pip install --no-cache-dir -r /tmp/requirements.txt \
|
||||
&& rm /tmp/requirements.txt
|
||||
|
||||
# No secrets baked in — S3 creds come from a mounted K8s Secret / env at runtime
|
||||
USER appuser
|
||||
WORKDIR /home/appuser/work
|
||||
|
||||
COPY --chown=appuser:appuser test_script.py /home/appuser/test_script.py
|
||||
|
||||
EXPOSE 8888
|
||||
|
||||
CMD ["jupyter", "lab", \
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
name: "a" # TODO: Remove this and use path instead
|
||||
|
||||
image:
|
||||
repository: registry.bouvais.lu/tenant-jupyter
|
||||
tag: "1.0.0"
|
||||
repository: registry.bouvais.lu/tenant/jupyter
|
||||
tag: "1.0.1"
|
||||
|
||||
resources:
|
||||
requests:
|
||||
@@ -12,8 +10,3 @@ resources:
|
||||
cpu: "1"
|
||||
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