update build files
This commit is contained in:
parent
2bc0fb3049
commit
1efdda050b
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
gin-bin
|
||||
config.yml
|
||||
.idea/
|
||||
/bin/
|
||||
/bin/*
|
||||
mg-telegram
|
11
Dockerfile
11
Dockerfile
@ -1,12 +1,9 @@
|
||||
FROM golang:1.9.3-stretch as ca-certs
|
||||
FROM scratch
|
||||
|
||||
COPY --from=ca-certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
FROM golang:1.9.3-stretch
|
||||
|
||||
WORKDIR /
|
||||
ADD ./bin/mg-telegram /
|
||||
ADD ./templates/ /templates/
|
||||
|
||||
EXPOSE 3001
|
||||
|
||||
ENTRYPOINT ["/mg-telegram", "--config", "/config.yml"]
|
||||
|
||||
CMD ["run"]
|
||||
ENTRYPOINT ["/mg-telegram", "run"]
|
||||
|
29
Makefile
29
Makefile
@ -1,8 +1,9 @@
|
||||
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
SRC_DIR=$(ROOT_DIR)
|
||||
MIGRATIONS_DIR=$(ROOT_DIR)/migrations
|
||||
CONFIG_FILE=$(ROOT_DIR)/config.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")
|
||||
|
||||
ifndef GOPATH
|
||||
@ -11,25 +12,31 @@ endif
|
||||
|
||||
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:
|
||||
@echo "==> Running gofmt"
|
||||
@gofmt -l -s -w $(SRC_DIR)
|
||||
|
||||
install: fmt
|
||||
@echo "==> Running go get"
|
||||
deps:
|
||||
@echo "==> Installing dependencies"
|
||||
$(eval DEPS:=$(shell cd $(SRC_DIR) \
|
||||
&& go list -f '{{join .Imports "\n"}}{{ "\n" }}{{join .TestImports "\n"}}' ./... \
|
||||
| sort | uniq | tr '\r' '\n' | paste -sd ' ' -))
|
||||
@go get -d -v $(DEPS)
|
||||
|
||||
build: install
|
||||
@echo "==> Building"
|
||||
@go build -o $(BIN) -ldflags "-X common.build=${REVISION}" .
|
||||
@echo $(BIN)
|
||||
|
||||
migrate: build
|
||||
@${BIN} --config $(CONFIG_FILE) migrate -p ./migrations/
|
||||
|
||||
run: migrate
|
||||
@echo "==> Running"
|
||||
@${BIN} --config $(CONFIG_FILE) run
|
||||
migrate_test: build
|
||||
@${BIN} --config $(CONFIG_TEST_FILE) migrate
|
||||
|
||||
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…
Reference in New Issue
Block a user