Skip to content

Commit 7c400ae

Browse files
committed
Beeper pipeline
1 parent c1ae968 commit 7c400ae

File tree

7 files changed

+81
-133
lines changed

7 files changed

+81
-133
lines changed

.github/workflows/deploy.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and Deploy
2+
3+
on:
4+
push:
5+
6+
env:
7+
CI_REGISTRY_IMAGE: "${{ secrets.CI_REGISTRY }}/litestream"
8+
9+
jobs:
10+
build-docker:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Set up Docker Buildx
14+
uses: docker/setup-buildx-action@v2
15+
16+
- name: Login to registry
17+
uses: docker/login-action@v2
18+
with:
19+
registry: ${{ secrets.CI_REGISTRY }}
20+
username: ${{ secrets.CI_REGISTRY_USER }}
21+
password: ${{ secrets.CI_REGISTRY_PASSWORD }}
22+
23+
- name: Docker Build
24+
uses: docker/build-push-action@v2
25+
with:
26+
cache-from: ${{ env.CI_REGISTRY_IMAGE }}:latest
27+
pull: true
28+
file: Dockerfile
29+
build-args: LITESTREAM_VERSION=${{ github.sha }}
30+
tags: ${{ env.CI_REGISTRY_IMAGE }}:${{ github.sha }}
31+
push: true
32+
33+
deploy-docker:
34+
runs-on: ubuntu-latest
35+
needs:
36+
- build-docker
37+
if: github.ref == 'refs/heads/beeper'
38+
steps:
39+
- name: Login to registry
40+
uses: docker/login-action@v2
41+
with:
42+
registry: ${{ secrets.CI_REGISTRY }}
43+
username: ${{ secrets.CI_REGISTRY_USER }}
44+
password: ${{ secrets.CI_REGISTRY_PASSWORD }}
45+
46+
- uses: beeper/docker-retag-push-latest@main
47+
with:
48+
image: ${{ env.CI_REGISTRY_IMAGE }}

.github/workflows/release.docker.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.github/workflows/release.linux.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

Dockerfile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,23 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
99
--mount=type=cache,target=/go/pkg \
1010
go build -ldflags "-s -w -X 'main.Version=${LITESTREAM_VERSION}' -extldflags '-static'" -tags osusergo,netgo,sqlite_omit_load_extension -o /usr/local/bin/litestream ./cmd/litestream
1111

12+
# to make copy a single layer later
13+
COPY etc/sqlite3 etc/aws-k8s-sa-provider /usr/local/bin/
1214

1315
FROM alpine:3.17.2
14-
COPY --from=builder /usr/local/bin/litestream /usr/local/bin/litestream
16+
ENV AWS_SDK_LOAD_CONFIG=1 \
17+
AWS_CONFIG_FILE=/etc/aws-config
18+
19+
# for debugging and cleanup
20+
RUN apk add --no-cache sqlite curl aws-cli && \
21+
mkdir /root/.aws
22+
23+
COPY etc/aws-config /etc/
24+
COPY --from=builder \
25+
/usr/local/bin/litestream \
26+
/usr/local/bin/sqlite3 \
27+
/usr/local/bin/aws-k8s-sa-provider \
28+
/usr/local/bin/
29+
1530
ENTRYPOINT ["/usr/local/bin/litestream"]
1631
CMD []

etc/aws-config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[default]
2+
credential_process = /usr/local/bin/aws-k8s-sa-provider

etc/aws-k8s-sa-provider

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
DATEFMT=%Y-%m-%dT%H:%M:%SZ
3+
[ -z "$SERVICE_ACCOUNT_TOKEN" ] && exit 1
4+
[ -f "$SERVICE_ACCOUNT_TOKEN" ] || exit 1
5+
cat << EOF
6+
{
7+
"Version": 1,
8+
"AccessKeyId": "aws-k8s-sa-provider@$(date +$DATEFMT)",
9+
"SecretAccessKey": "n/a",
10+
"SessionToken": "$(cat $SERVICE_ACCOUNT_TOKEN)",
11+
"Expiration": "$(date -ud @$(($(date -u +%s) + 300)) +$DATEFMT)"
12+
}
13+
EOF

etc/sqlite3

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec /usr/bin/sqlite3 -cmd "PRAGMA foreign_keys=ON; PRAGMA journal_mode=WAL; PRAGMA wal_autocheckpoint=0; PRAGMA busy_timeout=5000;" "$@"

0 commit comments

Comments
 (0)