go的Dockerfile docker-compose.yml
阿新 • • 發佈:2020-09-16
Dockerfile
FROM go_gin #WORKDIR $GOPATH/src/github.com/EDDYCJY/go-gin-example #COPY . $GOPATH/src/github.com/EDDYCJY/go-gin-example #RUN mkdir /code WORKDIR /code ADD . /code RUN go get gopkg.in/redis.v4 RUN go get golang.org/x/crypto/ssh RUN go get github.com/dgrijalva/jwt-go RUN go get github.com/gin-gonic/gin RUN go get github.com/swaggo/gin-swagger RUN go get github.com/swaggo/gin-swagger/swaggerFiles RUN go get github.com/alecthomas/template RUN go build main.go EXPOSE 8000
docker build -t . go_0819 # 打包為 image
docker-compose.yml
version: "3" services: web_gin: restart: always image: go_0819 command: bash -c "cd go_srv2/;go run main.go" volumes: - .:/code - /root/sdk/platform/storage/material/SenseFace/API/v40:/material ports: - "8818:8818" nginx: #image: docker.io/nginx #./nginx #build: ./nginx image: ngx_0729 ports: - "80:3030" #- "8001:3030" environment: - TZ=Asia/Shanghai volumes:- ./nginx.conf:/etc/nginx/nginx.conf:ro #- ./static:/usr/share/nginx/html/static:ro #- ./media:/usr/share/nginx/html/media:ro links: - web_gin depends_on: - web_gin restart: always
docker-compose up -d #執行