当前位置 博文首页 > 文章内容

    go的Dockerfile docker-compose.yml

    作者:旧楚布衣 栏目:未分类 时间:2020-09-16 10:01:20

    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  #运行