Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/jupyter-base-image-build-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build and Push Docker Image

on:
push:
branches:
- '**'
paths:
- 'jupyter-base-image/**'
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
nauedu/nau-analytics-base-jupyter
tags: |
type=sha

- name: Build Docker image (no push yet)
uses: docker/build-push-action@v6
with:
context: ./
file: ./jupyter-base-image/Dockerfile
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push Docker image (branch-specific)
if: ${{ github.event_name != 'pull_request' }}
run: |
set -eux
IMAGE_NAME="nauedu/nau-analytics-base-jupyter"
SHA_TAG=$(echo "${GITHUB_SHA}" | head -c7)

if [ "${GITHUB_REF_NAME}" = "main" ]; then
# Tag and push with 'latest' and SHA
docker tag $IMAGE_NAME:sha-$SHA_TAG $IMAGE_NAME:latest
docker tag $IMAGE_NAME:sha-$SHA_TAG $IMAGE_NAME:$SHA_TAG

docker push $IMAGE_NAME:latest
docker push $IMAGE_NAME:$SHA_TAG

echo "✅ Pushed tags 'latest' and '$SHA_TAG' for main branch to https://hub.docker.com/r/$IMAGE_NAME/tags"
else
# Tag and push with branch name
BRANCH_TAG=$(echo "${GITHUB_REF_NAME}" | tr '/' '-')
docker tag $IMAGE_NAME:sha-$SHA_TAG $IMAGE_NAME:$BRANCH_TAG
docker push $IMAGE_NAME:$BRANCH_TAG

echo "✅ Pushed branch tag '$BRANCH_TAG' to https://hub.docker.com/r/$IMAGE_NAME/tags"
fi
2 changes: 2 additions & 0 deletions jupyter-base-image/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**
!./*
27 changes: 27 additions & 0 deletions jupyter-base-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM nauedu/nau-analytics-base-spark:latest

# Env for Jupyter + PySpark
ENV HOME=/home/spark \
JUPYTER_PORT=8888 \
JUPYTER_DIR=/opt/spark/work-dir/notebooks \
PYSPARK_PYTHON=/usr/local/bin/python3.11 \
PYSPARK_DRIVER_PYTHON=/usr/local/bin/python3.11 \
PYTHONPATH="${SPARK_HOME}/python"

USER root

# garante dirs + permissões antes de instalar
RUN mkdir -p "${JUPYTER_DIR}" /home/spark \
&& chown -R 185:185 /home/spark /opt/spark

# PySpark + JupyterLab + libs
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir jupyterlab==4.2.5

RUN pip install --no-cache-dir git+https://github.com/fccn/nau-analytics-utils.git@main#subdirectory=common_libs/utils
USER 185
WORKDIR ${JUPYTER_DIR}

EXPOSE 8888

ENTRYPOINT ["bash","-lc","jupyter lab --ip=0.0.0.0 --port=${JUPYTER_PORT} --no-browser --ServerApp.root_dir=${JUPYTER_DIR} --ServerApp.token='' --ServerApp.password=''"]