-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add github action to build docker images
- Loading branch information
1 parent
a29e3ae
commit d00d0ee
Showing
4 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: build and push docker | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
branches: | ||
- 218-create-docker-image | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Decide the docker image version number | ||
run: | | ||
if [[ -f ./docker/build-docker-image-version.txt ]]; then | ||
echo "DOCKER_IMAGE_TAG=$( tail -n 1 ./docker/build-docker-image-version.txt )" >> $GITHUB_ENV | ||
else | ||
echo "DOCKER_IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV | ||
fi | ||
echo ${{ env.DOCKER_IMAGE_TAG }} | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Build and push gplately amd64 | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./docker/Dockerfile | ||
push: true | ||
platforms: linux/amd64 | ||
provenance: false | ||
tags: | | ||
gplates/gplately:amd64-${{ env.DOCKER_IMAGE_TAG }} | ||
ghcr.io/gplates/gplately:amd64-${{ env.DOCKER_IMAGE_TAG }} | ||
- | ||
name: Build and push gplately arm64 | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./docker/Dockerfile | ||
push: true | ||
platforms: linux/arm64 | ||
provenance: false | ||
tags: | | ||
gplates/gplately:arm64-${{ env.DOCKER_IMAGE_TAG }} | ||
ghcr.io/gplates/gplately:arm64-${{ env.DOCKER_IMAGE_TAG }} | ||
- | ||
name: Create cross-platform images | ||
run: | | ||
docker buildx imagetools create -t gplates/gplately:${{ env.DOCKER_IMAGE_TAG }} gplates/gplately:amd64-${{ env.DOCKER_IMAGE_TAG }} gplates/gplately:arm64-${{ env.DOCKER_IMAGE_TAG }} | ||
docker buildx imagetools create -t ghcr.io/gplates/gplately:${{ env.DOCKER_IMAGE_TAG }} ghcr.io/gplates/gplately:amd64-${{ env.DOCKER_IMAGE_TAG }} ghcr.io/gplates/gplately:arm64-${{ env.DOCKER_IMAGE_TAG }} | ||
- | ||
name: Create the latest tags | ||
if: | ||
run: | | ||
if [[ -f build-docker-images.txt ]]; then | ||
docker buildx imagetools create -t gplates/gplately:latest gplates/gplately:amd64-${{ env.DOCKER_IMAGE_TAG }} gplates/gplately:arm64-${{ env.DOCKER_IMAGE_TAG }} | ||
docker buildx imagetools create -t ghcr.io/gplates/gplately:latest ghcr.io/gplates/gplately:amd64-${{ env.DOCKER_IMAGE_TAG }} ghcr.io/gplates/gplately:arm64-${{ env.DOCKER_IMAGE_TAG }} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# | ||
# to build this docker container image | ||
# step 1: git clone https://github.com/GPlates/gplately.git | ||
# step 2: go into folder gplately | ||
# step 3: docker build -f docker/Dockerfile -t gplates/gplately . | ||
# | ||
# run the docker container | ||
# docker run --rm -ti -p 8888:8888 -v `pwd`:/workspace/my_stuff gplates/gplately | ||
# | ||
|
||
# if error, try with --no-cache option | ||
|
||
FROM mambaorg/micromamba:1.5.8 | ||
|
||
LABEL org.opencontainers.image.authors="michael.chin@sydney.edu.au" | ||
LABEL version="v1.3.0" | ||
|
||
USER root | ||
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y | ||
|
||
USER $MAMBA_USER | ||
COPY --chown=$MAMBA_USER:$MAMBA_USER ./docker/env.yaml /tmp/env.yaml | ||
RUN micromamba install -y -n base -f /tmp/env.yaml && \ | ||
micromamba clean --all --yes | ||
|
||
ARG MAMBA_DOCKERFILE_ACTIVATE=1 | ||
|
||
COPY --chown=$MAMBA_USER:$MAMBA_USER . /tmp/gplately | ||
RUN pip3 install /tmp/gplately | ||
RUN rm -rf /tmp/gplately | ||
|
||
COPY --chown=$MAMBA_USER:$MAMBA_USER ./Notebooks /workspace/Notebooks | ||
|
||
WORKDIR /workspace | ||
|
||
EXPOSE 8888 | ||
|
||
CMD ["jupyter", "notebook", "--no-browser", "--ip=0.0.0.0", "--NotebookApp.token=''"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# this file is used to control the docker image version tag. | ||
# only the last line has effect. | ||
|
||
v1.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: base | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- python=3.11 | ||
- pip | ||
- gplately | ||
- jupyter | ||
- moviepy |