Skip to content

Commit

Permalink
clinic: add build job to the github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshgngwr committed Oct 25, 2023
1 parent 8222af9 commit a8c692e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 3 deletions.
68 changes: 67 additions & 1 deletion .github/workflows/clinic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ on:

env:
JDK_DISTRIBUTION: temurin
JAVA_VERSION: 17
JAVA_VERSION: 21
NODE_VERSION: 21

jobs:
tests:
Expand All @@ -40,10 +41,75 @@ jobs:
with:
distribution: ${{ env.JDK_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- name: Setup Lein Dependency Cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-lein-${{ hashFiles('clinic/project.clj') }}

# can't use `services.[id].options` to add Docker health checks because
# HAPI has a scratch docker image without a shell installation.
- name: HAPI FHIR Health Check
run: while ! curl -sSI "http://localhost:8090"; do sleep 5; done
- name: Run Tests
run: lein test

build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.event_name == 'push' # skip for pull requests.
needs:
- tests
permissions:
contents: read
packages: write
defaults:
run:
working-directory: ./clinic
steps:
- name: Checkout Source
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: ${{ env.JDK_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: clinic/package-lock.json
- name: Setup Lein Dependency Cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-lein-${{ hashFiles('clinic/project.clj') }}
- name: Build CLJS
run: |
npm install
npx shadow-cljs release app
- name: Build Uberjar
run: lein uberjar
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker Image Tags
id: docker-image-tags
run: |
image_name=ghcr.io/nilenso/ashutosh-onboarding/clinic
image_tags="${image_name}:latest"
if [[ "$GITHUB_REF" =~ refs/tags/* ]]; then
image_tags="${image_tags},${image_name}:${{ github.ref_name }}"
fi
echo "tags=$image_tags" >> "$GITHUB_OUTPUT"
- name: Build and Push Latest Docker Image
uses: docker/build-push-action@v5
with:
context: clinic
push: true
tags: ${{ steps.docker-image-tags.outputs.tags }}
4 changes: 4 additions & 0 deletions clinic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM eclipse-temurin:21-jre
LABEL org.opencontainers.image.source="https://github.com/nilenso/ashutosh-onboarding"
COPY target/uberjar/clinic-latest-standalone.jar /app.jar
CMD ["java", "-jar", "/app.jar"]
2 changes: 1 addition & 1 deletion clinic/project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject clinic "0.1.0-SNAPSHOT"
(defproject clinic "latest"
:description "Onboarding project #2"
:url "https://github.com/nilenso/ashutosh-onboarding/blob/main/clinic"
:dependencies [[aero "1.1.6"]
Expand Down
3 changes: 2 additions & 1 deletion clinic/src/clj/clinic/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
(:require [clinic.config :as config]
[clinic.routes.core :as routes]
[mount.core :as mount]
[ring.adapter.jetty :as jetty]))
[ring.adapter.jetty :as jetty])
(:gen-class))

(defonce server (atom nil))

Expand Down

0 comments on commit a8c692e

Please sign in to comment.