Skip to content

Commit 1e24cfe

Browse files
committed
switch to go binary
Signed-off-by: Avi Deitcher <[email protected]>
1 parent e3f3bf6 commit 1e24cfe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+6194
-1462
lines changed

.github/workflows/ci.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ jobs:
2424
steps:
2525
- name: checkout
2626
uses: actions/checkout@v3
27+
- uses: actions/setup-go@v3
28+
with:
29+
go-version: '1.19'
30+
- name: golangci-lint
31+
uses: golangci/golangci-lint-action@v3
32+
with:
33+
version: latest
34+
- name: Build
35+
run: go build -o dist/mysql-backup -v .
36+
- name: vet
37+
run: make vet
38+
- name: Test
39+
run: make test
40+
- name: Integration Test
41+
run: make integration_test
2742
- name: Set up QEMU
2843
uses: docker/setup-qemu-action@v2
2944
- name: Set up Docker Buildx

.github/workflows/release.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,24 @@ jobs:
3131
with:
3232
username: ${{ secrets.DOCKER_USERNAME }}
3333
password: ${{ secrets.DOCKER_PASSWORD }}
34-
- name: Build and push
35-
id: docker_build
34+
- name: Docker meta
35+
id: meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
# list of Docker images to use as base name for tags
39+
images: |
40+
${{env.IMAGE_NAME}}
41+
# generate Docker tags based on the following events/attributes
42+
# for any semver, including rc and alpha, etc. take the tag as is
43+
# for ones that are exactly X.Y.Z, also tag it as latest
44+
tags: |
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=latest
47+
- name: Build and push semver tag
48+
id: docker_build_push_semver
3649
uses: docker/build-push-action@v2
3750
with:
3851
push: true
3952
platforms: linux/amd64,linux/arm64
4053
tags: |
41-
${{env.IMAGE_NAME}}:${{ github.ref_name }}
42-
${{env.IMAGE_NAME}}:latest
54+
${{ steps.meta.outputs.tags }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist/
2+
tmp/

Dockerfile

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
# mysql backup image
2-
FROM alpine:3.17
3-
LABEL org.opencontainers.image.authors="https://github.com/deitch"
2+
FROM golang:1.19.6-alpine3.17 as build
3+
4+
COPY . /src/mysql-backup
5+
WORKDIR /src/mysql-backup
46

5-
# install the necessary client
6-
# the mysql-client must be 10.3.15 or later
7-
RUN apk add --update 'mariadb-client>10.3.15' mariadb-connector-c bash python3 py3-pip samba-client shadow openssl coreutils && \
8-
rm -rf /var/cache/apk/* && \
9-
touch /etc/samba/smb.conf && \
10-
pip3 install awscli
7+
RUN mkdir /out && go build -o /out/mysql-backup .
8+
9+
# we would do from scratch, but we need basic utilities in order to support pre/post scripts
10+
FROM alpine:3.17
11+
LABEL org.opencontainers.image.authors="https://github.com/databacker"
1112

1213
# set us up to run as non-root user
13-
RUN groupadd -g 1005 appuser && \
14-
useradd -r -u 1005 -g appuser appuser
15-
# add home directory for user so IRSA AWS auth works
16-
RUN mkdir -p /home/appuser && chmod 0755 /home/appuser && chown appuser /home/appuser
17-
# ensure smb stuff works correctly
18-
RUN mkdir -p /var/cache/samba && chmod 0755 /var/cache/samba && chown appuser /var/cache/samba && chown appuser /var/lib/samba/private
14+
RUN apk add bash
15+
RUN addgroup -g 1005 appuser && \
16+
adduser -u 1005 -G appuser -D appuser
1917
USER appuser
2018

21-
# install the entrypoint
22-
COPY functions.sh /
19+
COPY --from=build /out/mysql-backup /mysql-backup
20+
2321
COPY entrypoint /entrypoint
2422

2523
# start

Makefile

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ push: build
1313
docker tag $(BUILDIMAGE) $(TARGET)
1414
docker push $(TARGET)
1515

16-
test_dump:
17-
cd test && DEBUG=$(DEBUG) ./test_dump.sh
16+
integration_test:
17+
go test -v ./test --tags=integration
1818

19-
test_cron:
20-
cd test && ./test_cron.sh
19+
integration_test_debug:
20+
dlv --wd=./test test ./test --build-flags="-tags=integration"
2121

22-
test_source_target:
23-
cd test && ./test_source_target.sh
22+
vet:
23+
go vet --tags=integration ./...
2424

25-
test_restore:
26-
cd test && ./test_restore.sh
25+
test: unit_test integration_test
2726

28-
test: test_dump test_restore test_cron test_source_target
27+
unit_test:
28+
go test -v ./...
2929

3030
.PHONY: clean-test-stop clean-test-remove clean-test
3131
clean-test-stop:
@@ -39,15 +39,5 @@ clean-test-remove:
3939
$(eval IDS:=$(shell docker ps -a --filter label=mysqltest -q))
4040
@if [ -n "$(IDS)" ]; then docker rm $(IDS); fi
4141
@echo
42-
@echo Remove Volumes
43-
$(eval IDS:=$(shell docker volume ls --filter label=mysqltest -q))
44-
@if [ -n "$(IDS)" ]; then docker volume rm $(IDS); fi
45-
@echo
46-
47-
clean-test-network:
48-
@echo Remove Networks
49-
$(eval IDS:=$(shell docker network ls --filter label=mysqltest -q))
50-
@if [ -n "$(IDS)" ]; then docker network rm $(IDS); fi
51-
@echo
5242

53-
clean-test: clean-test-stop clean-test-remove clean-test-network
43+
clean-test: clean-test-stop clean-test-remove

README-bash.md

Lines changed: 381 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)