Skip to content

Commit

Permalink
feat: build & push docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Akeboshiwind committed Feb 15, 2024
1 parent dee5f5d commit 6fa56cd
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
.clj-kondo
.yarn
.shadow-cljs
.lsp
node_modules
resources/public/js/compiled
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Build & Push Docker

on:
push:
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-docker:
runs-on: ubuntu-latest
if: github.repository == 'xtdb/xt-fiddle' && github.ref == 'refs/heads/main'
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.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.REGISTRY }}/${{ env.IMAGE_NAME }}
- 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: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 -A:cljs -P

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


FROM clojure: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

0 comments on commit 6fa56cd

Please sign in to comment.