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
51 changes: 41 additions & 10 deletions .github/workflows/packer-build-ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

---
name: Packer build

Expand All @@ -13,6 +14,8 @@ on:
paths:
- "**.pkr.hcl"

workflow_dispatch:

env:
REGISTRY: ghcr.io

Expand All @@ -24,15 +27,26 @@ jobs:
packages: write

name: packer


services:
registry:
image: registry:2
ports:
- 5000:5000
- 32000:5000

env:
local-repo: localhost:32000/mirc-ctp
local-tag: ci

steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand All @@ -49,14 +63,31 @@ jobs:
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get -q update && sudo apt-get -yq install packer

- name: Build Artifacts
run: |
[[ -f Makefile ]] && make .state_ctp-docker
CHANGED_FILES=$(git diff --name-only ${{github.event.before}}..${{github.event.after}} |grep '\.pkr\.hcl$')
for FILE in "${CHANGED_FILES[@]}"; do
packer validate -syntax-only "${FILE}"
[[ $? -eq 0 ]] && packer build -color=false -on-error=abort "${FILE}"
done
[[ -f Makefile ]] && make .state_ctp-docker repo=${{ env.local-repo}} tag=${{ env.local-tag }}
echo "mirc-ctp-build-ver=$(cat latest-build)" >> $GITHUB_ENV
docker push ${{ env.local-repo}}:${{ env.local-tag }}
env:
PACKER_LOG: 1

- name: Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/mirc-ctp
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=sha
type=raw,value=${{ env.mirc-ctp-build-ver }}

- name: Push docker image
uses: akhilerm/tag-push-action@v2.0.0
with:
src: ${{ env.local-repo}}:${{ env.local-tag }}
dst: |
${{ steps.meta.outputs.tags }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ output_*
.*.swp
.state_*
output-*
CTP-installer.jar
latest-build
Binary file removed CTP-installer.jar
Binary file not shown.
25 changes: 13 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
tag = $(shell date +%Y%m%d)

repo = ghcr.io/australian-imaging-service/mirc-ctp
source = https://github.com/johnperry/CTP.git
repo = localhost:32000/mirc-ctp
tag = $(shell cat latest-build)

all : .state_ctp-docker .state_ctp-ovf .state_ctp-vagrant .state_ctp-lxd

.state_ctp : mirc-ctp.json mirc-ctp.service src/CTP.tar.gz src/linux-x86_64 nocloud.iso
packer build mirc-ctp.json && touch state/mirc-ctp

# DE_FILES = $(shell find docker-entrypoint.d -type f)
# .state_ctp-docker : mirc-ctp.json CTP-installer.jar docker-entrypoint.sh docker-entrypoint.d $(DE_FILES)
# packer build -only=docker mirc-ctp.json
# touch .state_ctp-docker

.state_ctp-docker: ctp.pkr.hcl CTP-installer.jar
packer build -var='repo=$(repo)' -var='tag=["$(tag)"]' ctp.pkr.hcl
touch .state_ctp-docker


.state_ctp-ovf : mirc-ctp.json mirc-ctp.service CTP-installer.jar focal-server-cloudimg-amd64.ova nocloud.iso
packer build -only=virtualbox-ovf mirc-ctp.json
touch .state_ctp-ovf
Expand All @@ -28,8 +22,14 @@ all : .state_ctp-docker .state_ctp-ovf .state_ctp-vagrant .state_ctp-lxd
packer build -only=lxd mirc-ctp.json
touch .state_ctp-lxd

CTP-installer.jar :
curl -L -o./CTP-installer.jar http://mirc.rsna.org/download/CTP-installer.jar
CTP-installer.jar:
git clone $(source)
# cp -r CTP-old CTP
cd CTP; \
version=$$(git log -n 1 --date=format:'%Y%m%d' products/CTP-installer.jar | grep Date | cut -d ' ' -f 4); \
echo v$$version > ../latest-build
mv CTP/products/CTP-installer.jar ./
rm -fr CTP

focal-server-cloudimg-amd64.ova :
curl -L -o./focal-server-cloudimg-amd64.ova https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.ova
Expand All @@ -43,3 +43,4 @@ clean :
rm -f focal-server-cloudimg-amd64.ova
rm -f nocloud.iso
rm -f .state_*
rm -f latest-build
29 changes: 16 additions & 13 deletions ctp.pkr.hcl
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
build {
name = "docker"
name = "ctp"
sources = [
"source.docker.alpine"
"source.docker.ctp"
]
provisioner "file" {
sources = [
"CTP-installer.jar",
"config-serveronly.xml",
"Launcher.properties",
"run.sh"
"entrypoint.sh"
]
destination = "/tmp/"
}
provisioner "shell" {
inline = [
"apk update",
"apk add --no-cache tzdata",
"apt update",
"mkdir -p /JavaPrograms/ && cd /JavaPrograms",
"jar xf /tmp/CTP-installer.jar CTP",
"mv /tmp/config-serveronly.xml /JavaPrograms/CTP/config.xml",
"mv /tmp/Launcher.properties /JavaPrograms/CTP/",
"rm -f /tmp/CTP-installer.jar"
]
}
post-processor "docker-tag" {
repository = var.repo
tags = var.tag
post-processors {
post-processor "docker-tag" {
repository = var.repo
tags = var.tag
}
# post-processor "docker-push" {
# only = ["docker.ctp"]
# }
}
}
variable "repo" {
type = string
# default = "ghcr.io/australian-imaging-service/mirc-ctp"
}
variable "tag" {
type = list(string)
}
source "docker" "alpine" {
image = "openjdk:8u212-jdk-alpine3.9"
source "docker" "ctp" {
image = "openjdk:8u322-jdk-slim-bullseye"
commit = true
changes = [
"LABEL org.opencontainers.image.source https://github.com/australian-imaging-service/ctp-build",
"USER root",
"EXPOSE 1080 1443 25055",
"WORKDIR /JavaPrograms/CTP",
"ENTRYPOINT [\"/bin/sh\", \"/tmp/run.sh\"]"
"ENTRYPOINT [\"/bin/bash\", \"/tmp/entrypoint.sh\"]"
]
}
}
3 changes: 2 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
#!/bin/bash
set -x
if [ ! -z $timezone ]; then
unlink /etc/localtime
ln -s /usr/share/zoneinfo/$timezone /etc/localtime
else
echo "timezone environment variable is not set"
Expand Down