Skip to content

Commit

Permalink
ci: add back in docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Akeboshiwind committed Jun 12, 2024
1 parent 4257436 commit b15f492
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
42 changes: 42 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Build & Push Docker

on:
push:
branches:
- main

env:
GH_REGISTRY: ghcr.io

jobs:
build-and-push-github:
runs-on: ubuntu-latest
if: github.repository == 'xtdb/xt-fiddle'
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.GH_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.GH_REGISTRY }}/${{ github.repository }}
tags: |
type=sha,format=short
type=sha,format=long
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM clojure:temurin-21-tools-deps-alpine AS frontend-build
WORKDIR /app

# Install build deps
RUN apk add --update nodejs npm yarn

# Install node deps
COPY package.json .yarnrc.yml yarn.lock .
RUN yarn install

# Install clojure build deps
COPY deps.edn .
RUN clojure -P -M:cljs:dev

# Build the frontend
# TODO: Copy over only cljs files?
COPY . .
RUN npx shadow-cljs release app


FROM clojure:temurin-21-tools-deps-alpine
WORKDIR /app

# Install the runtime deps
COPY deps.edn .
RUN clojure -P

# Add the source & frontend code
COPY --from=frontend-build /app/resources/public/js/compiled /app/resources/public/js/compiled
# TODO: Copy over only clj files?
COPY . .
CMD clojure -X:prod
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"-Dio.netty.tryReflectionSetAccessible=true"]}

:prod
{:exec-fn main/-main
{:exec-fn xt-play.main/-main
:jvm-opts ["--add-opens=java.base/java.nio=ALL-UNNAMED"
"-Dio.netty.tryReflectionSetAccessible=true"]}

Expand Down

0 comments on commit b15f492

Please sign in to comment.