diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..ba729c4 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,19 @@ +name: Docker Image CI + +on: + push: + branches: [ "*" ] + tags: [ "v*" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build the Docker image + run: beta/docker-build.sh test diff --git a/beta/Dockerfile b/beta/Dockerfile index 5700cf0..4629280 100644 --- a/beta/Dockerfile +++ b/beta/Dockerfile @@ -13,20 +13,20 @@ FROM golang:bookworm AS builder RUN ldd --version WORKDIR /build COPY . . -RUN cd bld-dir && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./bld.go -RUN cd bld-dir && ./bld -is args-bld -RUN cd db && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build cnvrtExec.go -RUN cd db && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build cnvrtDesc.go -RUN cd sim-dir && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./sim.go +# RUN cd bld-dir && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./bld.go +# RUN cd bld-dir && ./bld -is args-bld +# RUN cd db && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build cnvrtExec.go +# RUN cd db && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build cnvrtDesc.go +# RUN cd sim-dir && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./sim.go # Production phase FROM debian:bookworm -RUN apt update && apt upgrade -y && apt install -y \ - python3 \ - python3-tk \ - python3-pil \ - python3-pil.imagetk vim-nox \ - python3-yaml \ - python3-matplotlib +#RUN apt update && apt upgrade -y && apt install -y \ +# python3 \ +# python3-tk \ +# python3-pil \ +# python3-pil.imagetk vim-nox \ +# python3-yaml \ +# python3-matplotlib WORKDIR /app COPY --from=builder /build/. . diff --git a/beta/docker-build.sh b/beta/docker-build.sh index ab3c382..7afce23 100755 --- a/beta/docker-build.sh +++ b/beta/docker-build.sh @@ -1,9 +1,39 @@ -#!/bin/sh -ex +#!/bin/bash -e # Copyright 2024 The Board of Trustees of the University of Illinois -TAG=ghcr.io/iti/pcesapps-beta:v0.1.1 -TAG2=ghcr.io/iti/pcesapps-beta:latest -cp ../go.mod ../go.sum . -docker build --no-cache -t $TAG -t $TAG2 . -docker push $TAG -docker push $TAG2 +# Usage: docker-build.sh [suffix [version ...]] +# Builds a docker image +# and pushes it with the tags +# ghcr.io/iti/pocesapps-$suffix:$version1 +# ghcr.io/iti/pocesapps-$suffix:$version2 +# ... +# The default value of "$suffix" is test. +# Additionally, versions of $(date) and "latest" +# are always created +# +# To test your code from the command line: +# ./docker-build.sh +# ./docker-run.sh +# That creates ghcr.io.iti/pcesapps-test:latest +# +# Whenever you git push a branch, the ci/cd runs: +# ./docker-build.sh dev +# This creates ghcr.io/iti/pcesappos-dev:latest +# +# Whever your git push a tag, the ci/cd runs: +# ./docker-build.shy beta $tag +# This creates ghcr.io/iti/pcesapps-beta:$tag + +pfx="ghcr.io/illinoisadams/doc-test" +pfx="ghcr.io/iti/pcesapps" + +now=$(date -u +%F-%H-%M-%S) +image="$pfx-"${1:-"test"} +latest=( ${1:+"latest"} "$@" ) + +docker build --no-cache -t "$image:$now" . +docker push "$image:$now" +for v in "${latest[@]}" ; do + docker tag "$image:$now" "$image:$v" + docker push "$image:$v" +done