update build files
This commit is contained in:
parent
2bc0fb3049
commit
1efdda050b
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
|||||||
gin-bin
|
gin-bin
|
||||||
config.yml
|
config.yml
|
||||||
.idea/
|
.idea/
|
||||||
/bin/
|
/bin/*
|
||||||
mg-telegram
|
mg-telegram
|
11
Dockerfile
11
Dockerfile
@ -1,12 +1,9 @@
|
|||||||
FROM golang:1.9.3-stretch as ca-certs
|
FROM golang:1.9.3-stretch
|
||||||
FROM scratch
|
|
||||||
|
|
||||||
COPY --from=ca-certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
ADD ./bin/mg-telegram /
|
||||||
|
ADD ./templates/ /templates/
|
||||||
|
|
||||||
EXPOSE 3001
|
EXPOSE 3001
|
||||||
|
|
||||||
ENTRYPOINT ["/mg-telegram", "--config", "/config.yml"]
|
ENTRYPOINT ["/mg-telegram", "run"]
|
||||||
|
|
||||||
CMD ["run"]
|
|
||||||
|
29
Makefile
29
Makefile
@ -1,8 +1,9 @@
|
|||||||
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
SRC_DIR=$(ROOT_DIR)
|
SRC_DIR=$(ROOT_DIR)
|
||||||
|
MIGRATIONS_DIR=$(ROOT_DIR)/migrations
|
||||||
CONFIG_FILE=$(ROOT_DIR)/config.yml
|
CONFIG_FILE=$(ROOT_DIR)/config.yml
|
||||||
CONFIG_TEST_FILE=$(ROOT_DIR)/config_test.yml
|
CONFIG_TEST_FILE=$(ROOT_DIR)/config_test.yml
|
||||||
BIN=$(ROOT_DIR)/mg-telegram
|
BIN=$(ROOT_DIR)/bin/mg-telegram
|
||||||
REVISION=$(shell git describe --tags 2>/dev/null || git log --format="v0.0-%h" -n 1 || echo "v0.0-unknown")
|
REVISION=$(shell git describe --tags 2>/dev/null || git log --format="v0.0-%h" -n 1 || echo "v0.0-unknown")
|
||||||
|
|
||||||
ifndef GOPATH
|
ifndef GOPATH
|
||||||
@ -11,25 +12,31 @@ endif
|
|||||||
|
|
||||||
export GOPATH := $(GOPATH):$(ROOT_DIR)
|
export GOPATH := $(GOPATH):$(ROOT_DIR)
|
||||||
|
|
||||||
|
build: deps fmt
|
||||||
|
@echo "==> Building"
|
||||||
|
@go build -o $(BIN) -ldflags "-X common.build=${REVISION}" .
|
||||||
|
@echo $(BIN)
|
||||||
|
|
||||||
|
run: migrate
|
||||||
|
@echo "==> Running"
|
||||||
|
@${BIN} --config $(CONFIG_FILE) run
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
@echo "==> Running gofmt"
|
@echo "==> Running gofmt"
|
||||||
@gofmt -l -s -w $(SRC_DIR)
|
@gofmt -l -s -w $(SRC_DIR)
|
||||||
|
|
||||||
install: fmt
|
deps:
|
||||||
@echo "==> Running go get"
|
@echo "==> Installing dependencies"
|
||||||
$(eval DEPS:=$(shell cd $(SRC_DIR) \
|
$(eval DEPS:=$(shell cd $(SRC_DIR) \
|
||||||
&& go list -f '{{join .Imports "\n"}}{{ "\n" }}{{join .TestImports "\n"}}' ./... \
|
&& go list -f '{{join .Imports "\n"}}{{ "\n" }}{{join .TestImports "\n"}}' ./... \
|
||||||
| sort | uniq | tr '\r' '\n' | paste -sd ' ' -))
|
| sort | uniq | tr '\r' '\n' | paste -sd ' ' -))
|
||||||
@go get -d -v $(DEPS)
|
@go get -d -v $(DEPS)
|
||||||
|
|
||||||
build: install
|
|
||||||
@echo "==> Building"
|
|
||||||
@go build -o $(BIN) -ldflags "-X common.build=${REVISION}" .
|
|
||||||
@echo $(BIN)
|
|
||||||
|
|
||||||
migrate: build
|
migrate: build
|
||||||
@${BIN} --config $(CONFIG_FILE) migrate -p ./migrations/
|
@${BIN} --config $(CONFIG_FILE) migrate -p ./migrations/
|
||||||
|
|
||||||
run: migrate
|
migrate_test: build
|
||||||
@echo "==> Running"
|
@${BIN} --config $(CONFIG_TEST_FILE) migrate
|
||||||
@${BIN} --config $(CONFIG_FILE) run
|
|
||||||
|
migrate_down: build
|
||||||
|
@${BIN} --config $(CONFIG_FILE) migrate -v down
|
||||||
|
35
docker-compose-prebuild.yml
Normal file
35
docker-compose-prebuild.yml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
version: '2.1'
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:9.6
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: mg_telegram
|
||||||
|
POSTGRES_PASSWORD: mg_telegram
|
||||||
|
POSTGRES_DATABASE: mg_telegram
|
||||||
|
ports:
|
||||||
|
- ${POSTGRES_ADDRESS:-127.0.0.1:5434}:5432
|
||||||
|
|
||||||
|
mg_migrate:
|
||||||
|
image: golang:1.9.3-stretch
|
||||||
|
working_dir: /mg_telegram_migrate
|
||||||
|
user: ${UID:-1000}:${GID:-1000}
|
||||||
|
volumes:
|
||||||
|
- ./:/mg_telegram_migrate/
|
||||||
|
links:
|
||||||
|
- postgres
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
command: make migrate
|
||||||
|
|
||||||
|
mg_telegram:
|
||||||
|
image: hub.retailcrm.pro/message-gateway/transport-telegram:latest
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./config.yml:/config.yml
|
||||||
|
ports:
|
||||||
|
- ${MG_TELEGRAM_ADDRESS:-3001}:3001
|
||||||
|
links:
|
||||||
|
- postgres
|
||||||
|
depends_on:
|
||||||
|
- mg_migrate
|
Loading…
x
Reference in New Issue
Block a user