docker 自动部署go项目

配合webhook,可以实现自动部署

Dockerfile

FROM golang AS build-env

ADD ./config.toml /go/bin/config.toml

RUN echo "#!/bin/bash\n\
cd /go/src/project\n\
go build\n\
./project\n\
" >> build.sh

RUN chmod +x build.sh

ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.io
ENV LANG C.UTF-8
ENV GOCACHE=/go/pkg/go-build

EXPOSE 8080
VOLUME ["/go/pkg","/go/src/project"]

 docker-compose.yaml

version: "3"
services:

  b2btradeserver:
    network_mode: host
    restart: always
    build:
      context: ./
      dockerfile: Dockerfile
    tty: true
    environment:
      TZ: Asia/Shanghai
    ports:
      - 8080:8080
    volumes:
      - /opt/GoPath/pkg:/go/pkg
      - /opt/GoPath/src/project:/go/src/project
上一篇:如何安装pkg-config


下一篇:MOOC ROS笔记 1