Skip to content

Commit c55f108

Browse files
committed
feat: add build number to the settings page
1 parent ba49685 commit c55f108

6 files changed

Lines changed: 32 additions & 3 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ jobs:
5555
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}:buildcache
5656
cache-to: type=registry,ref=${{ env.DOCKER_IMAGE }}:buildcache,mode=max
5757
platforms: linux/amd64,linux/arm64
58+
build-args: |
59+
NEXT_PUBLIC_APP_VERSION=${{ steps.version.outputs.tag }}
5860
5961
- name: Image digest
6062
run: echo ${{ steps.meta.outputs.digest }}

DEPLOYMENT.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,29 @@ docker pull rmcampos/syncable:latest
1717
### Option 2: Build the Docker Image Locally
1818

1919
```bash
20-
docker build -t rmcampos/syncable:latest .
20+
docker build --build-arg NEXT_PUBLIC_APP_VERSION=local-snapshot -t rmcampos/syncable:latest .
2121
```
2222

2323
### Run the Container
2424

2525
#### Using environment variables:
2626
```bash
27-
docker run -d \
27+
docker run -d -p 5432:5432 --rm \
28+
--name db \
29+
-e POSTGRES_DB="postgres" \
30+
-e POSTGRES_USER="postgres" \
31+
-e POSTGRES_PASSWORD="default" \
32+
postgres:15.8-bookworm
33+
34+
# Then run the create table script, from the project root directory
35+
docker exec -i db psql -U postgres -d postgres < init-db.sql
36+
37+
DBHOST=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db)
38+
39+
docker run -d --rm \
2840
--name syncable \
2941
-p 3000:3000 \
30-
-e DATABASE_URL="postgresql://user:password@host:5432/database" \
42+
-e DATABASE_URL="postgresql://postgres:default@$DBHOST:5432/postgres" \
3143
-e NODE_ENV=production \
3244
rmcampos/syncable:latest
3345
```

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ WORKDIR /app
1818
COPY --from=deps /app/node_modules ./node_modules
1919
COPY . .
2020

21+
ARG NEXT_PUBLIC_APP_VERSION
22+
2123
# Set environment variables for build
2224
ENV NEXT_TELEMETRY_DISABLED=1
2325
ENV NODE_ENV=production
26+
ENV NEXT_PUBLIC_APP_VERSION=${NEXT_PUBLIC_APP_VERSION}
2427

2528
# Build the Next.js application
2629
RUN corepack enable && corepack prepare yarn@1.22.22 --activate

components/settings/general-settings.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,14 @@ export function GeneralSettings({
398398
</Button>
399399
</CardFooter>
400400
</Card>
401+
402+
{process.env.NEXT_PUBLIC_APP_VERSION && (
403+
<div className="mt-4 text-center">
404+
<p className="text-xs text-muted-foreground">
405+
Build {process.env.NEXT_PUBLIC_APP_VERSION}
406+
</p>
407+
</div>
408+
)}
401409
</div>
402410
);
403411
}

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ services:
3232
environment:
3333
DATABASE_URL: postgresql://postgres:default@db:5432/postgres
3434
NODE_ENV: development
35+
NEXT_PUBLIC_APP_VERSION: local-snapshot
3536
command: >
3637
bash -c "
3738
yarn install &&

next.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ try {
1414
/** @type {import('next').NextConfig} */
1515
const nextConfig = {
1616
output: 'standalone', // Enable standalone mode for Docker deployment
17+
env: {
18+
NEXT_PUBLIC_APP_VERSION: process.env.NEXT_PUBLIC_APP_VERSION || '1.0.0',
19+
},
1720
eslint: {
1821
ignoreDuringBuilds: true,
1922
},

0 commit comments

Comments
 (0)