Add Docker Hub packaging tasks

This commit is contained in:
wpetit 2020-06-17 23:47:49 +02:00
parent a13caf3e4d
commit 3a1d08661b
2 changed files with 47 additions and 0 deletions

View File

@ -1,5 +1,7 @@
DOKKU_HOST := dokku@dev.lookingfora.name DOKKU_HOST := dokku@dev.lookingfora.name
SHELL := /bin/bash SHELL := /bin/bash
DOCKER_IMAGE_NAME ?= bornholm/hydra-passwordless
DOCKER_IMAGE_TAG ?= latest
build: vendor build: vendor
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
@ -69,6 +71,27 @@ dokku-deploy-sso:
$(if $(shell git config remote.dokku-sso.url),, git remote add dokku-sso $(DOKKU_HOST):sso) $(if $(shell git config remote.dokku-sso.url),, git remote add dokku-sso $(DOKKU_HOST):sso)
git push -f dokku-sso $(shell git rev-parse HEAD):refs/heads/master git push -f dokku-sso $(shell git rev-parse HEAD):refs/heads/master
docker-build:
docker build \
--build-arg="HTTP_PROXY=$(HTTP_PROXY)" \
--build-arg="HTTPS_PROXY=${HTTP_PROXY}" \
--build-arg="https_proxy=${https_proxy}" \
--build-arg="http_proxy=${http_proxy}" \
-t hydra-passwordless:latest \
-f ./misc/docker/Dockerfile \
.
docker-run:
docker run \
-it --rm \
-p 3000:3000 \
hydra-passwordless:latest
docker-release: docker-build
docker image tag hydra-passwordless:latest $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
docker login
docker push $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
clean: clean:
rm -rf release rm -rf release
rm -rf data rm -rf data

24
misc/docker/Dockerfile Normal file
View File

@ -0,0 +1,24 @@
FROM golang:1.14 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
EXPOSE 3000
CMD ["bin/server", "-workdir", "/app", "-config", "server.yml"]