From ceb14e53e894bfe7e040d04fee52a9a61a4008d2 Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Thu, 5 Dec 2024 09:28:39 -0800 Subject: [PATCH 1/9] updated workflow file for docker image --- .github/workflows/docker-image.yml | 54 ++++++++++-------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b24a031a4..acdb6a1a3 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,63 +3,43 @@ name: Docker Image CI/CD on: push: branches: - - master - pull_request: - branches: - - master - + - karan jobs: push_to_registry: name: Push Docker Image to Docker Hub if: github.event_name == 'push' runs-on: ubuntu-latest steps: - - name: Check Repository + - name: Checkout Repository uses: actions/checkout@v4 - - name: Cache SBT Dependencies - uses: actions/cache@v4 - with: - path: | - ~/.ivy2 - ~/.sbt - key: ${{ runner.os }}-sbt-${{ hashFiles('**/Build.sbt') }} - restore-keys: | - ${{ runner.os }}-sbt- - - name: Login to Docker Registry uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_EMAIL }} password: ${{ secrets.DOCKER_HUB_PASSWORD }} - - name: Build and Push Docker Image to Registry - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: teamfemrdev/teamfemr:latest - - build: - name: Build Docker Image on Pull Request - if: github.event_name == 'pull_request' - runs-on: ubuntu-latest - steps: - - name: Check Repository - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Cache SBT Dependencies + - name: Cache Docker Dependencies uses: actions/cache@v4 with: - path: | - ~/.ivy2 - ~/.sbt + path: sbt-build-cache key: ${{ runner.os }}-sbt-${{ hashFiles('**/Build.sbt') }} restore-keys: | ${{ runner.os }}-sbt- - - name: Build Docker Image - uses: docker/build-push-action@v5 + - name: Inject sbt-build-cache + uses: reproducible-containers/buildkit-cache-dance@4b2444fec0c0fb9dbf175a96c094720a692ef810 # v2.1.4 + with: + cache-source: sbt-build-cache + + - name: Build and Push Docker Image to Registry + uses: docker/build-push-action@v6 with: context: . - push: false + cache-from: type=gha + cache-to: type=gha,mode=max + push: true + tags: teamfemrdev/teamfemr:latest From cefcf720c4da9278956d4420561cef1eeb954706 Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Thu, 5 Dec 2024 09:46:48 -0800 Subject: [PATCH 2/9] updated actions versions --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index acdb6a1a3..7a4ed2d70 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -31,7 +31,7 @@ jobs: ${{ runner.os }}-sbt- - name: Inject sbt-build-cache - uses: reproducible-containers/buildkit-cache-dance@4b2444fec0c0fb9dbf175a96c094720a692ef810 # v2.1.4 + uses: reproducible-containers/buildkit-cache-dance@v3.1.0 with: cache-source: sbt-build-cache @@ -41,5 +41,5 @@ jobs: context: . cache-from: type=gha cache-to: type=gha,mode=max - push: true + push: ${{ github.event_name != 'pull_request' }} tags: teamfemrdev/teamfemr:latest From c262c66c3cd397bae159e35fe63028e6c3ce5689 Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Thu, 5 Dec 2024 09:53:29 -0800 Subject: [PATCH 3/9] updated workflow file again --- .github/workflows/docker-image.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 7a4ed2d70..49a73d0f7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -23,17 +23,24 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Cache Docker Dependencies - uses: actions/cache@v4 + uses: actions/cache@v3 with: - path: sbt-build-cache - key: ${{ runner.os }}-sbt-${{ hashFiles('**/Build.sbt') }} + path: | + ~/.ivy2 + ~/.sbt + key: sbt-${{ runner.os }}-${{ hashFiles('**/build.sbt', '**/project/*.sbt') }} restore-keys: | - ${{ runner.os }}-sbt- + sbt-${{ runner.os }}- - - name: Inject sbt-build-cache + - name: Inject sbt cache into Docker uses: reproducible-containers/buildkit-cache-dance@v3.1.0 with: - cache-source: sbt-build-cache + cache-map: | + { + "~/.ivy2": "/root/.ivy2", + "~/.sbt": "/root/.sbt" + } + skip-extraction: ${{ steps.cache.outputs.cache-hit }} - name: Build and Push Docker Image to Registry uses: docker/build-push-action@v6 From 5781c3e3bce055d6e943ec48b5e125797470bf91 Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:01:58 -0800 Subject: [PATCH 4/9] updated again --- .github/workflows/docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 49a73d0f7..8d8a0961a 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -26,8 +26,8 @@ jobs: uses: actions/cache@v3 with: path: | - ~/.ivy2 - ~/.sbt + root/.ivy2 + root/.sbt key: sbt-${{ runner.os }}-${{ hashFiles('**/build.sbt', '**/project/*.sbt') }} restore-keys: | sbt-${{ runner.os }}- @@ -37,8 +37,8 @@ jobs: with: cache-map: | { - "~/.ivy2": "/root/.ivy2", - "~/.sbt": "/root/.sbt" + "root/.ivy2": "/root/.ivy2", + "root/.sbt": "/root/.sbt" } skip-extraction: ${{ steps.cache.outputs.cache-hit }} From 31b0b21df866b29166613d4a3c909f9c9f812e65 Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:47:34 -0800 Subject: [PATCH 5/9] removed buildx step --- .github/workflows/docker-image.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 8d8a0961a..d190848b7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,8 +2,7 @@ name: Docker Image CI/CD on: push: - branches: - - karan + jobs: push_to_registry: name: Push Docker Image to Docker Hub From 1276bda7971d6afa301d8299ff52dbecf3e2ab9a Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:48:56 -0800 Subject: [PATCH 6/9] updated workflow file --- .github/workflows/docker-image.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d190848b7..c9ae18dac 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,6 +2,8 @@ name: Docker Image CI/CD on: push: + branches: + - karan jobs: push_to_registry: @@ -18,9 +20,6 @@ jobs: username: ${{ secrets.DOCKER_HUB_EMAIL }} password: ${{ secrets.DOCKER_HUB_PASSWORD }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Cache Docker Dependencies uses: actions/cache@v3 with: From f6353f419f31bdb692a22ed2974ba9c2a325b827 Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:50:12 -0800 Subject: [PATCH 7/9] updated workflow file --- .github/workflows/docker-image.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index c9ae18dac..d190848b7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,8 +2,6 @@ name: Docker Image CI/CD on: push: - branches: - - karan jobs: push_to_registry: @@ -20,6 +18,9 @@ jobs: username: ${{ secrets.DOCKER_HUB_EMAIL }} password: ${{ secrets.DOCKER_HUB_PASSWORD }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Cache Docker Dependencies uses: actions/cache@v3 with: From 4d44bbc630058e6b1ab7d312cc13c92ba022f004 Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:21:08 -0800 Subject: [PATCH 8/9] updated Dockerfile --- Dockerfile | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b03f6931..eaa61c5d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,28 +22,28 @@ RUN apt-get update && apt-get install -y \ # Install curl #RUN \ - # apt-get update && \ - # apt-get -y install curl +# apt-get update && \ +# apt-get -y install curl # Install sbt #RUN \ - #mkdir /working/ && \ - #cd /working/ && \ - #curl -L -o sbt-$SBT_VERSION.deb https://repo.scala-sbt.org/scalasbt/debian/sbt-$SBT_VERSION.deb && \ - #dpkg -i sbt-$SBT_VERSION.deb && \ - #rm sbt-$SBT_VERSION.deb && \ - #apt-get update && \ - #apt-get install sbt && \ - #cd && \ - #rm -r /working/ && \ - #sbt sbtVersion +#mkdir /working/ && \ +#cd /working/ && \ +#curl -L -o sbt-$SBT_VERSION.deb https://repo.scala-sbt.org/scalasbt/debian/sbt-$SBT_VERSION.deb && \ +#dpkg -i sbt-$SBT_VERSION.deb && \ +#rm sbt-$SBT_VERSION.deb && \ +#apt-get update && \ +#apt-get install sbt && \ +#cd && \ +#rm -r /working/ && \ +#sbt sbtVersion COPY Build.sbt . COPY project ./project RUN --mount=type=cache,target=/root/.ivy2 \ - --mount=type=cache,target=/root/.sbt \ - sbt update + --mount=type=cache,target=/root/.sbt \ + sbt update # Setup path variables and copy fEMR into container #ENV PATH $PROJECT_HOME/activator/activator-dist-1.3.10/bin:$PATH @@ -70,9 +70,9 @@ RUN apk add --no-cache bash python3 py3-pip gcc python3-dev musl-dev linux-heade RUN pip3 install psutil #database variables -ENV DB_URL "jdbc:mysql://localhost:3306/femr_db?characterEncoding=UTF-8&useSSL=false" -ENV DB_USER "username" -ENV DB_PASS "password" +ENV DB_URL="jdbc:mysql://localhost:3306/femr_db?characterEncoding=UTF-8&useSSL=false" +ENV DB_USER="username" +ENV DB_PASS="password" COPY --from=builder /usr/src/app/target/universal/femr-* /opt/bin/femr From 37e0c5b85fd367c90d169da2f05c171d0a1782d4 Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:24:24 -0800 Subject: [PATCH 9/9] updated dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index eaa61c5d8..ea6e2a0f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM sbtscala/scala-sbt:eclipse-temurin-jammy-8u352-b08_1.9.0_2.12.17 AS builder #build varaibles #ENV SBT_VERSION 1.1.5 -ENV PROJECT_HOME /usr/src +ENV PROJECT_HOME=/usr/src #RUN mkdir -p $PROJECT_HOME/activator $PROJECT_HOME/app