Skip to content

Commit 9aa3380

Browse files
Remove Python and go-bindata (cesanta#302)
1 parent 52bfc9b commit 9aa3380

File tree

14 files changed

+197
-612
lines changed

14 files changed

+197
-612
lines changed

.github/workflows/docker-nightly.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,13 @@ jobs:
2121
- name: Checkout code
2222
uses: actions/checkout@v2
2323

24-
- name: Get Version
24+
- name: Get Build Data
2525
id: info
2626
run: |
2727
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
28-
29-
- name: make generate build
30-
run: |
31-
/usr/bin/env python3 -m pip install GitPython
32-
cd auth_server
33-
make deps generate build
34-
35-
- name: cp ca-certificates.crt
36-
run: |
37-
cp /etc/ssl/certs/ca-certificates.crt auth_server/ca-certificates.crt
28+
export TEMP=$(cd auth_server && go run gen_version.go)
29+
echo ::set-output name=version::$(echo -n $TEMP | awk '{print $1}')
30+
echo ::set-output name=build_id::$(echo -n $TEMP | awk '{print $2}')
3831
3932
- name: Determine Docker Tag
4033
uses: haya14busa/action-cond@v1
@@ -73,6 +66,9 @@ jobs:
7366
platforms: linux/amd64
7467
push: ${{ github.event_name == 'push' }}
7568
tags: cesanta/docker_auth:${{ steps.imagetag.outputs.value }}
69+
build-args: |
70+
VERSION=${{ steps.info.outputs.version }}
71+
BUILD_ID=${{ steps.info.outputs.build_id }}
7672
labels: |
7773
org.opencontainers.image.title=${{ github.event.repository.name }}
7874
org.opencontainers.image.description=${{ github.event.repository.description }}

.github/workflows/go_test.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ jobs:
1414
go-version: ${{ matrix.go-version }}
1515
- name: Checkout code
1616
uses: actions/checkout@v2
17-
- name: Install deps
18-
run: |
19-
python -m pip install --upgrade pip
20-
pip install GitPython
21-
cd auth_server
22-
python gen_version.py
2317
- name: Test
2418
run: |
2519
cd auth_server

auth_server/Dockerfile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
FROM busybox
2-
ADD auth_server /docker_auth/
3-
COPY ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
1+
FROM golang:1.16-alpine3.13 as build
2+
3+
ARG VERSION
4+
ENV VERSION "${VERSION}"
5+
ARG BUILD_ID
6+
ENV BUILD_ID "${BUILD_ID}"
7+
ARG CGO_EXTRA_CFLAGS
8+
9+
RUN apk add -U --no-cache ca-certificates make git gcc musl-dev
10+
11+
COPY . /build
12+
WORKDIR /build
13+
RUN make build
14+
15+
FROM alpine:3.13
16+
COPY --from=build /build/auth_server /docker_auth/
17+
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
418
ENTRYPOINT ["/docker_auth/auth_server"]
519
CMD ["/config/auth_config.yml"]
620
EXPOSE 5001

auth_server/Makefile

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,14 @@
11
MAKEFLAGS += --warn-undefined-variables
22
IMAGE ?= cesanta/docker_auth
3-
COMPRESS_BINARY ?= false
4-
CA_BUNDLE = /etc/ssl/certs/ca-certificates.crt
5-
VERSION = $(shell cat version.txt)
6-
7-
BUILDER_IMAGE ?= golang:1.16-alpine3.13
3+
VERSION ?= $(shell go run ./gen_version.go | awk '{print $$1}')
4+
BUILD_ID ?= $(shell go run ./gen_version.go | awk '{print $$2}')
85

96
.PHONY: %
107

118
all: build
129

13-
deps:
14-
go install github.com/go-bindata/go-bindata/go-bindata@latest
15-
16-
generate:
17-
go generate \
18-
github.com/cesanta/docker_auth/auth_server \
19-
github.com/cesanta/docker_auth/auth_server/authn/... \
20-
github.com/cesanta/docker_auth/auth_server/authz/... \
21-
github.com/cesanta/docker_auth/auth_server/mgo_session/... \
22-
github.com/cesanta/docker_auth/auth_server/server/...
23-
2410
build:
25-
CGO_ENABLED=0 go build -v --ldflags=--s
26-
27-
ca-certificates.crt:
28-
cp $(CA_BUNDLE) .
29-
30-
build-release: ca-certificates.crt
31-
docker run --rm -v $(PWD)/..:/src \
32-
$(BUILDER_IMAGE) sh -x -c "\
33-
apk update && apk add git make py3-pip && pip install GitPython && \
34-
cd /src/auth_server && \
35-
umask 0 && \
36-
go install github.com/go-bindata/go-bindata/go-bindata@latest && \
37-
make generate && \
38-
CGO_ENABLED=0 go build -v --ldflags=--s"
39-
@echo === Built version $$(cat version.txt) ===
11+
go build -v -ldflags="-X 'main.Version=${VERSION}' -X 'main.BuildID=${BUILD_ID}'"
4012

4113
auth_server:
4214
@echo
@@ -45,7 +17,7 @@ auth_server:
4517
@exit 1
4618

4719
docker-build:
48-
docker build -t $(IMAGE):latest .
20+
docker build --build-arg VERSION="${VERSION}" --build-arg BUILD_ID="${BUILD_ID}" -t $(IMAGE):latest .
4921
docker tag $(IMAGE):latest $(IMAGE):$(VERSION)
5022

5123
docker-tag-%:

auth_server/README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
### Building local image
22

33
```
4-
# copy ca certificate to /etc/ssl/certs/ca-certificates.crt
5-
pip install gitpython
64
mkdir -p /var/tmp/go/src/github.com/cesanta
75
cd /var/tmp/go/src/github.com/cesanta
86
git clone https://github.com/cesanta/docker_auth.git
97
cd docker_auth/auth_server
10-
export GOPATH=/var/tmp/go
11-
export PATH=$PATH:$GOPATH/bin
12-
# download dependencies
13-
make deps
14-
# build source
15-
make generate
16-
make
8+
make docker-build
179
```

auth_server/authn/authn.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@
1616

1717
package authn
1818

19-
//go:generate go-bindata -pkg authn -modtime 1 -mode 420 -nocompress data/
19+
import "embed"
20+
21+
//go:embed data/*
22+
var static embed.FS

0 commit comments

Comments
 (0)