Skip to content

Commit

Permalink
ci/cd test
Browse files Browse the repository at this point in the history
  • Loading branch information
illinoisrobert committed Aug 5, 2024
1 parent 1d73d3e commit e105893
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 19 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 12 additions & 12 deletions beta/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/. .
44 changes: 37 additions & 7 deletions beta/docker-build.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e105893

Please sign in to comment.