Merge branch 'develop'

This commit is contained in:
CareyWong 2020-03-20 15:09:35 +08:00
commit e06de1790e
5 changed files with 51 additions and 1 deletions

3
.env.example Normal file
View File

@ -0,0 +1,3 @@
MYURLS_PORT=8002
MYURLS_DOMAIN=example.com
MYURLS_TTL=90

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
.idea .idea
build/ build/
.env

17
Dockerfile Normal file
View 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"]

View File

@ -29,7 +29,16 @@ sudo apt-get install redis-server -y
## Docker ## Docker
TODO 现在你可以无需安装其他服务,使用 [docker-compose](https://docs.docker.com/compose/install/) 部署本项目。注:请自行修改 .env 中参数。
```shell script
git clone https://github.com/CareyWang/MyUrls.git MyUrls
cd MyUrls
cp .env.example .env
docker-compose up -d
```
## Install ## Install

19
docker-compose.yaml Normal file
View 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"