actency-mysql57-replication
Andrey Ivanov 2021-01-10 10:04:53 -05:00 committed by Andrey Ivanov
parent 3995e66713
commit 7c7ea01d6c
5 changed files with 63 additions and 1 deletions

14
Makefile Normal file
View File

@ -0,0 +1,14 @@
cdir = $(shell pwd)
up:
sudo -S docker-compose -f ./cicd/docker-compose.yml up -d --build
down: shutdown clean
shutdown:
sudo -S docker-compose -f ./cicd/docker-compose.yml down
clean:
sudo docker rmi $(sudo docker images | grep '<none>' | awk '{print $3}')
.PHONY: up down

14
cicd/app/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM golang:1.14 as builder
RUN mkdir -p /app
WORKDIR /app
COPY . .
RUN go get -d ./cmd/.
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o app ./cmd/.
FROM alpine:latest
ENV APP_SERVER_PORT $APP_SERVER_PORT
WORKDIR /
COPY --from=builder /app/app ./sbin
COPY --from=builder /app/templates ./templates
EXPOSE ${APP_SERVER_PORT}
ENTRYPOINT ["app"]

2
cicd/dbinit/init.sql Normal file
View File

@ -0,0 +1,2 @@
CREATE DATABASE IF NOT EXISTS `app`;
GRANT ALL ON `app`.* TO 'app'@'%' identified by 'app';

32
cicd/docker-compose.yml Normal file
View File

@ -0,0 +1,32 @@
version: '3'
services:
mysql:
image: mysql
hostname: "mysql"
container_name: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: app
MYSQL_USER: app
MYSQL_PASSWORD: app
volumes:
- ./dbinit:/docker-entrypoint-initdb.d
app:
build:
context: ..
dockerfile: ./cicd/app/Dockerfile
restart: always
environment:
APP_SERVER_ADDRESS: 0.0.0.0
APP_SERVER_PORT: 8080
APP_DSN_HOST: mysql
APP_DSN_PORT: 3306
APP_DSN_USER: app
APP_DSN_PASS: app
APP_DSN_BASE: app
ports:
- "8080:8080"

View File

@ -24,7 +24,7 @@ func init() {
func main() {
log.Println("Starting...")
m := martini.Classic()
app, err := application.New("application.conf", "APP")
app, err := application.New("", "APP")
if err != nil {
log.Fatal(fmt.Errorf("can't build app: %w", err).Error())
}