Skip to content

Commit

Permalink
Move Build Out of Docker Build Container
Browse files Browse the repository at this point in the history
In the Docker build container, artefacts can't be cached. So building
outside will be faster.
  • Loading branch information
alexanderkiel committed May 18, 2021
1 parent 0936f41 commit 08324b8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
7 changes: 1 addition & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
*
!modules
!resources
!src
!Dockerfile
!deps.edn
!pom.xml
!target
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,30 @@ jobs:
runs-on: ubuntu-20.04

steps:
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11'

- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
tools-deps: '1.10.3.822'

- name: Cache Local Maven Repo
uses: actions/cache@v2.1.5
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-maven-repo-build

- name: Check out Git repository
uses: actions/checkout@v2

- name: Build Uberjar
run: make uberjar

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

Expand All @@ -200,9 +221,16 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ghcr.io/samply/blaze:${{ github.sha }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ target
/nginx.conf
.cpcache
.cache
.env
16 changes: 6 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
FROM clojure:openjdk-11-tools-deps-1.10.1.727 as build

COPY . /build/

WORKDIR /build
RUN clojure -X:depstar uberjar :jar target/blaze-standalone.jar
FROM busybox as build

RUN mkdir -p /app/data

FROM gcr.io/distroless/java-debian10:11

WORKDIR /app

COPY --from=build --chown=nonroot:nonroot /app ./
COPY --from=build --chown=nonroot:nonroot /build/target/ ./
COPY --from=build --chown=nonroot:nonroot /app /app
COPY --chown=nonroot:nonroot target/blaze-standalone.jar /app/

WORKDIR /app
USER nonroot

ENV STORAGE="standalone"
ENV INDEX_DB_DIR="/app/data/index"
ENV TRANSACTION_DB_DIR="/app/data/transaction"
ENV RESOURCE_DB_DIR="/app/data/resource"

CMD ["blaze-standalone.jar", "-m", "blaze.core"]
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
VERSION := "0.11.0-beta.1"
MODULES := $(wildcard modules/*)

$(MODULES):
Expand All @@ -22,7 +21,7 @@ clean-root:
clean: $(MODULES) clean-root

uberjar:
clojure -X:depstar uberjar :jar target/blaze-${VERSION}-standalone.jar
clojure -X:depstar uberjar :jar target/blaze-standalone.jar

outdated:
clojure -M:outdated
Expand Down

0 comments on commit 08324b8

Please sign in to comment.