Docker deploy support
This commit is contained in:
parent
8e10c291eb
commit
939e69c927
3
.env.example
Normal file
3
.env.example
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
MYURLS_PORT=8002
|
||||||
|
MYURLS_DOMAIN=example.com
|
||||||
|
MYURLS_TTL=90
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
build/
|
build/
|
||||||
|
|
||||||
|
.env
|
||||||
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
FROM golang:1.13-alpine AS dependencies
|
||||||
|
WORKDIR /app
|
||||||
|
RUN go env -w GO111MODULE="on" && go env -w GOPROXY="https://goproxy.cn,direct"
|
||||||
|
|
||||||
|
COPY go.sum go.mod ./
|
||||||
|
RUN go mod tidy
|
||||||
|
|
||||||
|
FROM dependencies as build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY main.go ./
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o myurls main.go
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /app/myurls ./
|
||||||
|
EXPOSE 8002
|
||||||
|
ENTRYPOINT ["/app/myurls"]
|
||||||
19
docker-compose.yaml
Normal file
19
docker-compose.yaml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
myurls:
|
||||||
|
build: .
|
||||||
|
container_name: myurls
|
||||||
|
restart: always
|
||||||
|
env_file: .env
|
||||||
|
ports:
|
||||||
|
- "${MYURLS_PORT}:8002"
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
entrypoint: ["/app/myurls", "-domain", "${MYURLS_DOMAIN}", "-conn", redis:6379, "-ttl", "${MYURLS_TTL}"]
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: "redis:5"
|
||||||
|
container_name: redis
|
||||||
|
restart: always
|
||||||
|
expose:
|
||||||
|
- "6379"
|
||||||
Loading…
x
Reference in New Issue
Block a user