Skip to content
Open
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
105 changes: 105 additions & 0 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
# schedule:
# - cron: '39 23 * * *'
push:
# branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

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

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
#- name: Install cosign
# if: github.event_name != 'pull_request'
# uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
# with:
# cosign-release: 'v1.13.1'


# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2.5.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4.3.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image (don't push on PR)
# Since buildx is used, annotations must be set via outputs (for now)
# see https://github.com/docker/build-push-action/issues/447 for more
# provenance is to prevent unknown/unknown arch from being published, may be removed in future?
# see https://github.com/docker/build-push-action/issues/820 for more
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4.0.0
with:
context: build
platforms: linux/amd64, linux/arm64
provenance: false
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: |
type=image,name=target,annotation-index.org.opencontainers.image.description=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }},annotation-index.org.opencontainers.image.source=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.source'] }},annotation-index.org.opencontainers.image.licenses=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.licenses'] }}


# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
#- name: Sign the published Docker image
# if: ${{ github.event_name != 'pull_request' }}
# env:
# COSIGN_EXPERIMENTAL: "true"
# # This step uses the identity token to provision an ephemeral certificate
# # against the sigstore community Fulcio instance.
# run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}

57 changes: 1 addition & 56 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,56 +1 @@
FROM python:3.9-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl && \
echo "getting latest install script" && \
curl -fsSL https://code-server.dev/install.sh > install.sh && \
sh install.sh --version 4.5.1 && \
rm install.sh && \
apt-get -qq purge curl && \
apt-get -qq purge && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*

RUN apt-get update -q && \
apt-get install -yqq \
curl \
git \
htop \
nginx \
make \
tmux \
vim \
&& \
apt-get -qq purge && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*

# create user with a home directory
ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER=${NB_USER}
ENV HOME=/home/${NB_USER}

RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}

WORKDIR /work/
WORKDIR ${HOME}
USER ${NB_USER}
ENV PATH="/home/${NB_USER}/.local/bin:${PATH}"
ENV SHELL="/bin/bash"
COPY requirements.txt /tmp
RUN pip install -U pip
RUN pip install --no-cache -r /tmp/requirements.txt
COPY postBuild /tmp
COPY jupyter_notebook_config.py /home/${NB_USER}/.jupyter/
RUN sh /tmp/postBuild

# fix permissions
USER root
RUN chown -R ${NB_USER}:${NB_USER} /home/${NB_USER}/.jupyter/
USER ${NB_USER}

CMD code-server --auth none --bind-addr 0.0.0.0 --port 5000
FROM ghcr.io/ml-starter-packs/microservice-workshop:v0.0.1
56 changes: 56 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM python:3.9-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl && \
echo "getting latest install script" && \
curl -fsSL https://code-server.dev/install.sh > install.sh && \
sh install.sh --version 4.5.1 && \
rm install.sh && \
apt-get -qq purge curl && \
apt-get -qq purge && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*

RUN apt-get update -q && \
apt-get install -yqq \
curl \
git \
htop \
nginx \
make \
tmux \
vim \
&& \
apt-get -qq purge && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*

# create user with a home directory
ARG NB_USER=jovyan
ARG NB_UID=1000
ENV USER=${NB_USER}
ENV HOME=/home/${NB_USER}

RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}

WORKDIR /work/
WORKDIR ${HOME}
USER ${NB_USER}
ENV PATH="/home/${NB_USER}/.local/bin:${PATH}"
ENV SHELL="/bin/bash"
COPY requirements.txt /tmp
RUN pip install -U pip
RUN pip install --no-cache -r /tmp/requirements.txt
COPY postBuild /tmp
COPY jupyter_notebook_config.py /home/${NB_USER}/.jupyter/
RUN sh /tmp/postBuild

# fix permissions
USER root
RUN chown -R ${NB_USER}:${NB_USER} /home/${NB_USER}/.jupyter/
USER ${NB_USER}

CMD code-server --auth none --bind-addr 0.0.0.0 --port 5000
File renamed without changes.
File renamed without changes.
File renamed without changes.