Skip to content

Commit 79eaa25

Browse files
authored
Docker image for diagnostics-app (#243)
1 parent d1bd578 commit 79eaa25

File tree

8 files changed

+120
-1
lines changed

8 files changed

+120
-1
lines changed

.changeset/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@
1111
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
1212
"onlyUpdatePeerDependentsWhenOutOfRange": true,
1313
"updateInternalDependents": "out-of-range"
14+
},
15+
"privatePackages": {
16+
"tag": true,
17+
"version": true
1418
}
1519
}

.changeset/odd-beers-tease.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/diagnostics-app': minor
3+
---
4+
5+
Add docker image

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.git
2+
.idea
3+
4+
**/node_modules
5+
**/dist
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Diagnostics Image Build
2+
3+
on:
4+
push:
5+
6+
concurrency: ${{ github.workflow }}-${{ github.ref }}
7+
8+
jobs:
9+
build-docker-image:
10+
name: Build diagnostics-app Docker Image
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Build Image
20+
uses: docker/build-push-action@v5
21+
with:
22+
platforms: linux/amd64
23+
cache-from: type=registry,ref=${{vars.DIAGNOSTICS_DOCKER_REGISTRY}}:latest
24+
context: .
25+
file: ./tools/diagnostics-app/Dockerfile
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Publishes the Diagnostics App Docker image to DockerHub
2+
# This is triggered whenever the `diagnostics-app` package is versioned and tagged
3+
name: Diagnostics Image Release
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
tags:
9+
- '@powersync/diagnostics-app*'
10+
11+
concurrency: ${{ github.workflow }}-${{ github.ref }}
12+
13+
jobs:
14+
release-docker-image:
15+
name: Build and Release diagnostics-app Docker Image
16+
runs-on: ubuntu-latest
17+
if: github.ref == 'refs/heads/main'
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Login to Docker Hub
26+
uses: docker/login-action@v3
27+
with:
28+
username: ${{ secrets.DOCKERHUB_USERNAME }}
29+
password: ${{ secrets.DOCKERHUB_TOKEN }}
30+
31+
# This uses the service's package.json version for the Docker Image tag
32+
- name: Get Image Version from package.json
33+
id: get_version
34+
run: echo "IMAGE_VERSION=$(node -p "require('./tools/diagnostics-app/package.json').version")" >> $GITHUB_OUTPUT
35+
36+
- name: Build Image and Push
37+
uses: docker/build-push-action@v5
38+
with:
39+
platforms: linux/amd64
40+
cache-from: type=registry,ref=${{vars.DIAGNOSTICS_DOCKER_REGISTRY}}:latest
41+
context: .
42+
tags: ${{vars.DIAGNOSTICS_DOCKER_REGISTRY}}:latest,${{vars.DIAGNOSTICS_DOCKER_REGISTRY}}:${{steps.get_version.outputs.IMAGE_VERSION}}
43+
push: true
44+
file: ./tools/diagnostics-app/Dockerfile
45+
46+
# Updates the README section on the DockerHub page
47+
- name: Update repo description
48+
# Note that this 3rd party extention is recommended in the DockerHub docs:
49+
# https://docs.docker.com/build/ci/github-actions/update-dockerhub-desc/
50+
uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae # v4.0.0
51+
with:
52+
username: ${{ secrets.DOCKERHUB_USERNAME }}
53+
password: ${{ secrets.DOCKERHUB_TOKEN }}
54+
repository: ${{vars.DIAGNOSTICS_DOCKER_REGISTRY}}
55+
# This is the contents of what will be shown on DockerHub
56+
readme-filepath: ./tools/diagnostics-app/README.md

tools/diagnostics-app/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM node:22.5 AS builder
2+
WORKDIR /app
3+
4+
RUN npm i -g pnpm@9
5+
6+
COPY . /app
7+
8+
RUN pnpm i --frozen-lockfile --filter ./packages/react --filter ./packages/common --filter ./packages/web --filter ./tools/diagnostics-app
9+
RUN pnpm run --filter ./packages/react --filter ./packages/common --filter ./packages/web build
10+
RUN pnpm run --filter ./tools/diagnostics-app build
11+
12+
# === PROD ===
13+
14+
FROM nginx
15+
COPY ./tools/diagnostics-app/nginx.conf /etc/nginx/conf.d/default.conf
16+
COPY --from=builder /app/tools/diagnostics-app/dist /usr/share/nginx/html

tools/diagnostics-app/nginx.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
server {
2+
listen 80;
3+
server_name frontend;
4+
location / {
5+
root /usr/share/nginx/html;
6+
try_files $uri /index.html;
7+
}
8+
}

tools/diagnostics-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "diagnostics-app",
2+
"name": "@powersync/diagnostics-app",
33
"version": "0.2.2",
44
"private": true,
55
"scripts": {

0 commit comments

Comments
 (0)