Skip to content

Commit 263fa8e

Browse files
authored
Merge pull request #66 from FeTS-AI/docker_for_v1
Adding the Docker workflow for v1
2 parents 877f6bf + 7948858 commit 263fa8e

File tree

3 files changed

+166
-10
lines changed

3 files changed

+166
-10
lines changed

.github/workflows/docker-image.yml

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags: [ '*.*.*' ]
7+
pull_request:
8+
branches: [ master ]
9+
workflow_dispatch:
10+
inputs:
11+
versionTag:
12+
description: 'Version tag to push to Docker Hub (lowercase, alphanumeric)'
13+
required: true
14+
type: string
15+
16+
jobs:
17+
18+
build_test_push:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false # So that remaining jobs don't instantly quit if one fails (e.g, CPU/ROCm don't upload if CUDA just fails to push to ghcr...)
22+
# matrix:
23+
# include: # Platform locates Dockerfile ("Dockerfile-{PLATFORM}"), docker tag has to be all lowercase alphanumeric for mysterious docker reasons
24+
# - platform: CPU
25+
# dockertag: cpu
26+
# - platform: ROCm
27+
# dockertag: rocm
28+
29+
steps:
30+
- name: Check out the repository
31+
uses: actions/checkout@v3
32+
# with:
33+
# lfs: false
34+
# submodules: 'recursive'
35+
36+
# - name: Check if the repository has changed
37+
# run: ls -l
38+
39+
- name: Docker prune to save space # If you switch to self-hosted runners, this should be removed.
40+
run: echo y | docker system prune -a
41+
42+
- name: Check free space before
43+
run: |
44+
echo "Free space:"
45+
df -h
46+
47+
- name: Free Disk Space (Ubuntu)
48+
run: |
49+
sudo rm -rf /usr/local/lib/android
50+
sudo rm -rf /usr/share/dotnet
51+
52+
- name: Check free space after
53+
run: |
54+
echo "Free space:"
55+
df -h
56+
57+
# Install the cosign tool except on PR
58+
# https://github.com/sigstore/cosign-installer
59+
- name: Install cosign
60+
if: github.event_name != 'pull_request'
61+
uses: sigstore/cosign-installer@1e95c1de343b5b0c23352d6417ee3e48d5bcd422
62+
with:
63+
cosign-release: 'v1.4.0'
64+
65+
- name: Log into GitHub Packages registry (ghcr.io)
66+
if: github.event_name != 'pull_request'
67+
uses: docker/#-action@v2
68+
with:
69+
registry: ghcr.io
70+
username: ${{ github.actor }}
71+
password: ${{ secrets.GITHUB_TOKEN }}
72+
73+
# Extract metadata (tags, labels) for Docker
74+
# https://github.com/docker/metadata-action
75+
- name: Extract Docker metadata
76+
id: meta
77+
uses: docker/metadata-action@v4
78+
with:
79+
images: ghcr.io/fets-ai/front-end
80+
flavor: | # Handle prefixing and "latest" generation -- use "tags" property to specify events/tags further
81+
latest=true
82+
tags: |
83+
type=semver,pattern={{version}}
84+
type=ref,event=branch
85+
type=ref,event=pr
86+
type=ref,event=tag
87+
88+
# Build Docker Image (but don't push yet -- wait for the test step first).
89+
# https://github.com/docker/build-push-action
90+
- name: Build Docker images
91+
id: build
92+
uses: docker/build-push-action@v4
93+
with:
94+
context: .
95+
# cache-from: type=local,src=${{ github.workspace }}
96+
# build-args: --mount 'type=bind,src=${{ github.workspace }},target=/Front-End,readwrite' #-v ${{ github.workspace }}:/Front-End
97+
file: ./Dockerfile
98+
push: false
99+
load: true
100+
tags: ${{ steps.meta.outputs.tags }}
101+
labels: ${{ steps.meta.outputs.labels }}
102+
103+
# - uses: addnab/docker-run-action@v3
104+
# with:
105+
# username: ${{ github.actor }}
106+
# password: ${{ secrets.GITHUB_TOKEN }}
107+
# registry: ghcr.io
108+
# image: ghcr.io/fets-ai/front-end:latest
109+
# options: -v ${{ github.workspace }}:/Front-End
110+
# run: |
111+
# echo "Running Script"
112+
# /work/run-script
113+
# - name: Build the Docker image
114+
# run: docker build . -v /Front-End:/home/runner/work/Front-End/Front-End/ --file Dockerfile --tag ${{ steps.meta.outputs.tags }}
115+
116+
117+
# Run the image from the base entrypoint as a test
118+
- name: Test container with entrypoint
119+
# Run a tag we generated from the metadata extraction above -- they're all the same image, but echo it regardless just so we know.
120+
run: docker run --rm ghcr.io/fets-ai/front-end:latest -h
121+
122+
# Push Docker image with Buildx (but don't push on PR)
123+
# https://github.com/docker/build-push-action
124+
# This won't re-build the images fully or anything, they should already exist from the build step and use the cache.
125+
- name: Upload to Docker Hub (docker.io) and GitHub Packages (ghcr.io)
126+
id: upload
127+
if: github.event_name != 'pull_request'
128+
uses: docker/build-push-action@v4
129+
with:
130+
context: .
131+
file: ./Dockerfile
132+
push: true
133+
tags: ${{ steps.meta.outputs.tags }}
134+
labels: ${{ steps.meta.outputs.labels }}
135+
136+
# Below is for signing images (keyless) with cosign. But this adds confusing sha256-digest.sig tags to the container registry.
137+
# Leave this commented if container signing is not required.
138+
# # Sign the resulting Docker image digest except on PRs.
139+
# # Uses cosign keyless signing: https://github.com/sigstore/cosign/blob/main/KEYLESS.md
140+
# # This will only write to the public Rekor transparency log when the Docker
141+
# # repository is public to avoid leaking data. If you would like to publish
142+
# # transparency data even for private images, pass --force to cosign below.
143+
# # https://github.com/sigstore/cosign
144+
#- name: Sign published Docker image (ghcr.io)
145+
# if: ${{ github.event_name != 'pull_request' }}
146+
# env:
147+
# COSIGN_EXPERIMENTAL: "true"
148+
# # This step uses the identity token to provision an ephemeral certificate
149+
# # against the sigstore community Fulcio instance.
150+
# run: cosign sign ghcr.io/fets-ai/front-end@${{ steps.upload.outputs.digest }}
151+

Dockerfile

+14-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update -y
66

77
RUN apt-get install wget zip unzip software-properties-common gcc g++ make -y
88

9-
RUN apt-get update -y && add-apt-repository ppa:deadsnakes/ppa && apt update -y && apt install python3.7 python3.7-venv python3.7-dev python3-setuptools -y
9+
RUN apt-get update -y && add-apt-repository ppa:deadsnakes/ppa && apt update -y && apt install python3.7 python3.7-venv python3.7-dev python3-setuptools ffmpeg libsm6 libxext6 -y
1010

1111
# We will do git pull on the FeTS_Front-End master, because that is the repo using which the base image is made
1212
# We will not do compiles on the PR because the idea is that the Xenial build will check the build status of
@@ -20,21 +20,23 @@ RUN wget https://fets.projects.nitrc.org/FeTS_${VERSION}_Installer.bin && chmod
2020
# install FeTS and remove installer
2121
RUN yes yes | ./FeTS_${VERSION}_Installer.bin --target ./FeTS_${VERSION} -- --cudaVersion 11 && rm -rf ./FeTS_${VERSION}_Installer.bin
2222

23-
ENV PATH=./FeTS_${VERSION}/squashfs-root/usr/bin/:$PATH
24-
ENV LD_LIBRARY_PATH=./FeTS_${VERSION}/squashfs-root/usr/lib/:$LD_LIBRARY_PATH
23+
ENV PATH=/workspace/FeTS_${VERSION}/squashfs-root/usr/bin/:$PATH
24+
ENV LD_LIBRARY_PATH=/workspace/FeTS_${VERSION}/squashfs-root/usr/lib/:$LD_LIBRARY_PATH
25+
ENV SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL="True"
2526

2627
# set up environment and install correct version of pytorch
2728
RUN cd ./FeTS_${VERSION}/squashfs-root/usr/bin/OpenFederatedLearning && \
28-
rm -rf ./venv && python3.7 -m venv ./venv && \
29+
rm -rf ./venv && python3.7 -m venv ./venv && ./venv/bin/pip install Cython && \
30+
./venv/bin/pip install --upgrade pip setuptools wheel setuptools-rust && \
2931
./venv/bin/pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
3032

3133
RUN cd ./FeTS_${VERSION}/squashfs-root/usr/bin/OpenFederatedLearning && \
3234
./venv/bin/pip install wheel && \
33-
./venv/bin/pip install scikit-build && \
35+
./venv/bin/pip install scikit-build scikit-learn && \
3436
./venv/bin/pip install SimpleITK==1.2.4 && \
35-
./venv/bin/pip install protobuf==3.17.3 && \
36-
./venv/bin/pip install opencv-python==4.2.0.34 && \
37-
./venv/bin/pip install python-gdcm
37+
./venv/bin/pip install protobuf==3.17.3 grpcio==1.30.0 && \
38+
./venv/bin/pip install opencv-python==4.2.0.34
39+
# ./venv/bin/pip install python-gdcm
3840

3941
RUN cd ./FeTS_${VERSION}/squashfs-root/usr/bin/OpenFederatedLearning && \
4042
./venv/bin/pip install setuptools --upgrade && \
@@ -43,11 +45,14 @@ RUN cd ./FeTS_${VERSION}/squashfs-root/usr/bin/OpenFederatedLearning && \
4345
./venv/bin/pip install -e ./submodules/fets_ai/Algorithms/GANDLF && \
4446
cd ../LabelFusion && \
4547
rm -rf venv && python3.7 -m venv ./venv && \
48+
./venv/bin/pip install --upgrade pip setuptools wheel setuptools-rust && \
4649
./venv/bin/pip install -e .
4750

4851
# set up the docker for GUI
4952
ENV QT_X11_NO_MITSHM=1
5053
ENV QT_GRAPHICSSYSTEM="native"
5154

55+
RUN echo "Env paths\n" && echo $PATH && echo $LD_LIBRARY_PATH
56+
5257
# define entry point
53-
ENTRYPOINT ["/FeTS_\${VERSION}/bin/install/appdir/usr/bin/FeTS_CLI_Inference"]
58+
ENTRYPOINT ["/workspace/FeTS_0.0.9/squashfs-root/usr/bin/FeTS_CLI_Inference"]

0 commit comments

Comments
 (0)