Dokku deployment recipe

This commit is contained in:
wpetit 2020-05-20 19:29:13 +02:00
parent b996a07cbd
commit e26cb7ad49
4 changed files with 48 additions and 6 deletions

5
.dockerignore Normal file
View File

@ -0,0 +1,5 @@
/data
/.vscode
/vendor
/bin
/release

View File

@ -1,16 +1,17 @@
build: DOKKU_HOST := dokku@dev.lookingfora.name
SHELL := /bin/bash
build: vendor-server build:
CGO_ENABLED=0 go build -mod=vendor -v -o ./bin/server ./cmd/server CGO_ENABLED=0 go build -mod=vendor -v -o ./bin/server ./cmd/server
test: test:
go test -v -race ./... go test -v -race ./...
release: release: vendor
@$(SHELL) ./misc/script/release.sh @$(SHELL) ./misc/script/release.sh
vendor-%: vendor:
cd cmd/$* && go mod vendor go mod vendor
tidy: tidy:
go mod tidy go mod tidy
@ -27,4 +28,17 @@ clean:
rm -rf vendor rm -rf vendor
rm -rf bin rm -rf bin
dokku-build:
docker build \
-f ./misc/dokku/Dockerfile \
-t goweb-oidc-dokku:latest \
.
dokku-run:
docker run -it --rm -p 3002:3002 goweb-oidc-dokku:latest
dokku-deploy:
$(if $(shell git config remote.dokku-oidc-test.url),, git remote add dokku-oidc-test $(DOKKU_HOST):oidc-test)
git push -f dokku-oidc-test $(shell git rev-parse HEAD):refs/heads/master
.PHONY: lint watch build vendor tidy release .PHONY: lint watch build vendor tidy release

24
misc/dokku/Dockerfile Normal file
View File

@ -0,0 +1,24 @@
FROM golang:1.13 AS build
ARG HTTP_PROXY=
ARG HTTPS_PROXY=
ARG http_proxy=
ARG https_proxy=
RUN apt-get update && apt-get install -y build-essential git bash
COPY . /src
WORKDIR /src
RUN make ARCH_TARGETS=amd64 release
FROM busybox
COPY --from=build /src/release/server-linux-amd64 /app
WORKDIR /app
ENV HTTP_ADDRESS=:80
CMD ["bin/server", "-workdir", "/app", "-config", "server.yml"]

View File

@ -104,7 +104,6 @@ function release_server {
dump_default_conf 'server' $os $arch dump_default_conf 'server' $os $arch
copy 'server' $os $arch "$PROJECT_DIR/README.md" "README.md" copy 'server' $os $arch "$PROJECT_DIR/README.md" "README.md"
copy 'server' $os $arch "$PROJECT_DIR/cmd/server/public" "public"
copy 'server' $os $arch "$PROJECT_DIR/cmd/server/template" "template" copy 'server' $os $arch "$PROJECT_DIR/cmd/server/template" "template"
compress 'server' $os $arch compress 'server' $os $arch