From be73d2810f0d477fd01d6a91996e09969b854882 Mon Sep 17 00:00:00 2001 From: llitfkitfk Date: Mon, 23 Mar 2020 00:05:53 +0800 Subject: [PATCH] add docker support --- .dockerignore | 1 + Dockerfile | 24 ++++++++++++++++++++++++ docker-compose.yml | 38 ++++++++++++++++++++++++++++++++++++++ web/.dockerignore | 1 + web/Dockerfile | 5 +++++ 5 files changed, 69 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 web/.dockerignore create mode 100644 web/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..6f3439a3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +web \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bce2147c --- /dev/null +++ b/Dockerfile @@ -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 [] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..e2f65185 --- /dev/null +++ b/docker-compose.yml @@ -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 + + \ No newline at end of file diff --git a/web/.dockerignore b/web/.dockerignore new file mode 100644 index 00000000..b512c09d --- /dev/null +++ b/web/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 00000000..cce595dc --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,5 @@ +FROM node:lts-alpine AS builder + +WORKDIR /home/app + +COPY . . \ No newline at end of file