Permalink
Browse files

fix #79: switch from dep to go mod

  • Loading branch information...
kamilsk committed Jan 7, 2019
1 parent b39f912 commit 74177ebcaad3502f2d7e70b0ef0f2df79b8d97ed
Showing 706 changed files with 20,424 additions and 216,141 deletions.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 OctoLab, https://www.octolab.org/ <feedback@octolab.org>
Copyright (c) 2019 OctoLab, https://www.octolab.org/ <feedback@octolab.org>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -4,26 +4,19 @@ services:

db:
image: postgres:10-alpine
# build:
# context: ../db/context
# dockerfile: ../Dockerfile
env_file: ../db/.env
volumes:
- ../db/context/initdb.d:/docker-entrypoint-initdb.d

legacy:
image: php:fpm-alpine
# build:
# context: ../legacy/context
# dockerfile: ../Dockerfile
env_file: ../legacy/.env
volumes:
- ../legacy/context/:/var/www/html/:ro

migration:
image: kamilsk/guard:latest
build:
args: { PACKAGE: "${PACKAGE}" }
context: ../../../.
dockerfile: ./env/docker/service/Dockerfile
command: [ "migrate" ]
@@ -35,7 +28,6 @@ services:
service:
image: kamilsk/guard:latest
build:
args: { PACKAGE: "${PACKAGE}" }
context: ../../../.
dockerfile: ./env/docker/service/Dockerfile
command: [ "run", "--with-profiling", "--with-monitoring", "--with-grpc-gateway" ]
@@ -45,9 +37,6 @@ services:

server:
image: nginx:alpine
# build:
# context: ../server/context
# dockerfile: ../Dockerfile
depends_on:
- legacy
- service
@@ -4,8 +4,7 @@ set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE USER "guard" WITH PASSWORD 'guard';
CREATE DATABASE "guard";
GRANT ALL PRIVILEGES ON DATABASE "guard" TO "guard";
CREATE DATABASE "guard" WITH OWNER "guard";
\c "guard";
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
EOSQL
@@ -1,21 +1,21 @@
FROM golang:latest AS build

ARG PACKAGE

WORKDIR /go/src/${PACKAGE}
WORKDIR /src

ADD . .

ENV GOOS linux
ENV GOARCH amd64
ENV CGO_ENABLED 0
ENV GO111MODULE on
ENV PACKAGE github.com/kamilsk/guard

RUN echo "os: ${GOOS}" "arch: ${GOARCH}" "cgo: ${CGO_ENABLED}" \
RUN go env \
&& export _commit="-X ${PACKAGE}/pkg/cmd.commit=$(git rev-parse --short HEAD || echo 'none')" \
&& export _date="-X ${PACKAGE}/pkg/cmd.date=$(date -u +%FT%X%Z || echo 'unknown')" \
&& export _version="-X ${PACKAGE}/pkg/cmd.version=$(git describe --tags 2>&- || echo 'dev' | cut -d - -f 1)" \
&& go build -o /go/bin/service \
-ldflags "-s -w ${_commit} ${_date} ${_version}" ./cmd/guard
-ldflags "-s -w ${_commit} ${_date} ${_version}" -mod vendor ./cmd/guard


FROM alpine:latest AS service
@@ -1,7 +1,3 @@
ifndef PACKAGE
$(error Please define PACKAGE variable)
endif

ifndef VERSION
$(error Please define VERSION variable)
endif
@@ -14,79 +10,36 @@ docker-build:
-t kamilsk/guard:latest \
-t quay.io/kamilsk/guard:$(VERSION) \
-t quay.io/kamilsk/guard:latest \
--build-arg PACKAGE=$(PACKAGE) \
--force-rm --no-cache --pull --rm \
.

.PHONY: docker-build-db
docker-build-db:
docker build \
-t guard-db:$(VERSION) \
-f env/docker/db/Dockerfile \
--force-rm \
env/docker/db/context

.PHONY: docker-build-etcd
docker-build-etcd:
docker build \
-t guard-etcd:$(VERSION) \
-f env/docker/etcd/Dockerfile \
--force-rm \
env/docker/etcd/context

.PHONY: docker-build-legacy
docker-build-legacy:
docker build \
-t guard-legacy:$(VERSION) \
-f env/docker/legacy/Dockerfile \
--force-rm \
env/docker/legacy/context

.PHONY: docker-build-server
docker-build-server:
docker build \
-t guard-server:$(VERSION) \
-f env/docker/server/Dockerfile \
--force-rm \
env/docker/server/context

.PHONY: docker-build-service
docker-build-service:
docker build \
-t guard-service:$(VERSION) \
-f env/docker/service/Dockerfile \
--build-arg PACKAGE=$(PACKAGE) \
--force-rm \
.

.PHONY: docker-push
docker-push:
docker push kamilsk/guard:$(VERSION)
docker push kamilsk/guard:latest
docker push quay.io/kamilsk/guard:$(VERSION)
docker push quay.io/kamilsk/guard:latest

.PHONY: docker-refresh
docker-refresh:
docker images --all \
| grep '^kamilsk\/guard\s\+' \
| awk '{print $$3}' \
| xargs docker rmi -f &>/dev/null || true
docker pull kamilsk/guard:$(IMAGE_VERSION)



.PHONY: publish
publish: docker-build docker-push


.PHONY: docker-run-db
docker-run-db:
docker run --rm -it \
-p 5432:5432 \
guard-db:$(VERSION)

.PHONY: docker-run-etcd
docker-run-etcd:
docker run --rm -it \
-p 2379:2379 \
-p 2380:2380 \
guard-etcd:$(VERSION)

.PHONY: docker-run-service
docker-run-service:
.PHONY: docker-start
docker-start:
docker run --rm -it \
--env-file env/.env.example \
--name guard-dev \
-p 8080:8080 \
-p 8090:8090 \
-p 8091:8091 \
36 go.mod

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 74177eb

Please sign in to comment.