-
Notifications
You must be signed in to change notification settings - Fork 53
115 lines (97 loc) · 3.96 KB
/
Copy pathdocker-dev.yaml
File metadata and controls
115 lines (97 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Action to publish development Docker images
# Images are versioned as `0.0.0-{tag}-DATETIMESTAMP`
name: Development Image Release
on: workflow_dispatch
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: read
jobs:
release-docker-image:
name: Build and Release powersync-service Docker Image
runs-on: ubuntu-latest
environment: dockerhub
steps:
- name: Checkout
uses: actions/checkout@v5
with:
# check out full history
# Temporarily needed for changesets
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Enable Corepack
run: corepack enable
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Ensure Changesets
run: |
# If no changesets are available the status check will fail
# We should not continue if there are no changesets
pnpm changeset status
pnpm changeset version --snapshot dev
# This uses the service's package.json version for the Docker Image tag.
# The changeset command above must change this to a dev package version.
- name: Get dev service version from package.json
id: get_version
run: |
version="$(node -p "require('./service/package.json').version")"
node -e '
const semver = require("semver");
const version = process.argv[1];
const parsed = semver.parse(version);
if (!parsed) {
console.error("Service version " + version + " is not a valid semver version.");
process.exit(1);
}
const prerelease = parsed.prerelease.join(".");
if (!/^dev(?:[.-]|$)/.test(prerelease)) {
console.error("Service version " + version + " is not a dev snapshot version.");
process.exit(1);
}
' "$version"
echo "SERVICE_VERSION=$version" >> "$GITHUB_OUTPUT"
- name: Extract metadata for the image
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ vars.DOCKER_REGISTRY }}
labels: |
org.opencontainers.image.licenses=FSL-1.1-ALv2
org.opencontainers.image.version=${{ steps.get_version.outputs.SERVICE_VERSION }}
org.opencontainers.image.vendor=Journey Mobile, Inc
annotations: |
org.opencontainers.image.licenses=FSL-1.1-ALv2
org.opencontainers.image.version=${{ steps.get_version.outputs.SERVICE_VERSION }}
org.opencontainers.image.vendor=Journey Mobile, Inc
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- name: Build Image and Push
uses: docker/build-push-action@v6
with:
platforms: linux/arm64,linux/amd64
cache-from: type=registry,ref=${{vars.DOCKER_REGISTRY}}:latest
context: .
# This should not be taged as latest
tags: ${{vars.DOCKER_REGISTRY}}:${{steps.get_version.outputs.SERVICE_VERSION}}
file: ./service/Dockerfile
push: true
# Add labels and annotations from metadata-action above.
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
# Note: This includes build args in the published provenance.
# Do not use this if secrets are passed in as args.
provenance: mode=max
# Pre-generate an SBOM file, which can be used for vulnerability scanning or listing licenses.
sbom: true