add docker support

This commit is contained in:
llitfkitfk 2020-03-23 00:05:53 +08:00
parent eb03ccc271
commit be73d2810f
5 changed files with 69 additions and 0 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
web

24
Dockerfile Normal file
View File

@ -0,0 +1,24 @@
FROM golang:alpine AS builder
RUN apk add --no-cache git
WORKDIR /home/app
# comment this if using vendor
# ENV GOPROXY=https://mod.gokit.info
# COPY go.mod go.sum ./
# RUN go mod download
COPY . .
ENV GOPROXY=https://mod.gokit.info
RUN go build -o ./bin/monapi src/modules/monapi/monapi.go
FROM alpine:3.10
LABEL maintainer="llitfkitfk@gmail.com"
RUN apk add --no-cache ca-certificates
WORKDIR /app
COPY --from=builder /home/app/etc /app/etc
COPY --from=builder /home/app/bin /usr/local/bin
# ENTRYPOINT []
# CMD []

38
docker-compose.yml Normal file
View File

@ -0,0 +1,38 @@
version: "3"
volumes:
mysql-data:
services:
api:
build: .
image: api
monapi:
image: api
restart: always
command: monapi
web:
build:
context: web
restart: always
ports:
- 8010:8010
redis:
image: redis
restart: always
ports:
- 6379:6379
mysql:
image: mysql:5.7
restart: always
environment:
- MYSQL_ROOT_PASSWORD=1234
ports:
- 3306:3306
volumes:
- ./sql:/docker-entrypoint-initdb.d
- mysql-data:/var/lib/mysql

1
web/.dockerignore Normal file
View File

@ -0,0 +1 @@
node_modules

5
web/Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM node:lts-alpine AS builder
WORKDIR /home/app
COPY . .