5 changed files with 70 additions and 32 deletions
@ -1,28 +1,15 @@
@@ -1,28 +1,15 @@
|
||||
FROM ubuntu |
||||
FROM ubuntu:latest |
||||
|
||||
ENV DOCKER_PROXY="http://host.docker.internal:1081" |
||||
ENV NODE_REGISTRY="https://registry.npm.taobao.org" |
||||
ENV GOPROXY="https://goproxy.cn,direct" |
||||
ENV mongoURI="mongodb:27017" |
||||
|
||||
# set proxy and update |
||||
ENV HTTP_PROXY=$DOCKER_PROXY \ |
||||
HTTPS_PROXY=$DOCKER_PROXY \ |
||||
http_proxy=$DOCKER_PROXY \ |
||||
https_proxy=$DOCKER_PROXY |
||||
ENV PATH=$PATH:/usr/local/bin |
||||
COPY ./blotter /blotter |
||||
|
||||
RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates |
||||
RUN mv /etc/apt/sources.list /etc/apt/sources.list.back |
||||
RUN printf 'deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse\ndeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse\ndeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse\ndeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse' >> /etc/apt/sources.list |
||||
# gojieba 字典文件 |
||||
COPY ./temp/mod/github.com/ttys3/gojieba@v1.1.3/dict/hmm_model.utf8 /go/pkg/mod/github.com/ttys3/gojieba@v1.1.3/dict/hmm_model.utf8 |
||||
COPY ./temp/mod/github.com/ttys3/gojieba@v1.1.3/dict/idf.utf8 /go/pkg/mod/github.com/ttys3/gojieba@v1.1.3/dict/idf.utf8 |
||||
COPY ./temp/mod/github.com/ttys3/gojieba@v1.1.3/dict/jieba.dict.utf8 /go/pkg/mod/github.com/ttys3/gojieba@v1.1.3/dict/jieba.dict.utf8 |
||||
COPY ./temp/mod/github.com/ttys3/gojieba@v1.1.3/dict/stop_words.utf8 /go/pkg/mod/github.com/ttys3/gojieba@v1.1.3/dict/stop_words.utf8 |
||||
COPY ./temp/mod/github.com/ttys3/gojieba@v1.1.3/dict/user.dict.utf8 /go/pkg/mod/github.com/ttys3/gojieba@v1.1.3/dict/user.dict.utf8 |
||||
|
||||
|
||||
RUN unset HTTP_PROXY |
||||
RUN unset HTTPS_PROXY |
||||
RUN unset http_proxy |
||||
RUN unset https_proxy |
||||
|
||||
RUN apt-get update && apt-get install git screen golang nodejs npm yarn mongodb -y |
||||
RUN npm install -g yarn |
||||
RUN yarn config set registry $NODE_REGISTRY |
||||
RUN yarn config set proxy $DOCKER_PROXY |
||||
RUN service mongodb start |
||||
ENTRYPOINT [ "/blotter", "-address=0.0.0.0:50000"] |
@ -1,10 +1,33 @@
@@ -1,10 +1,33 @@
|
||||
#!/usr/bin/env bash |
||||
#!/bin/bash |
||||
|
||||
_date=$(date '+%Y-%m-%d %H:%M:%S') |
||||
_branch=$(git rev-parse --abbrev-ref HEAD); _branch="${_branch}@" |
||||
_version=$(git describe --abbrev=0 --tags 2>/dev/null); if [[ -z $_version ]]; then _version="v0.0.0"; fi |
||||
_ldflags="${_branch}${_version} (${_date})" |
||||
|
||||
go build -ldflags "-X 'main._version=${_ldflags}'" |
||||
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd) |
||||
IMAGE="golang:1.16.3" |
||||
|
||||
unset _date _branch _version _ldflags |
||||
|
||||
# 拉取镜像 |
||||
if [[ $(docker images ${IMAGE} | wc -l) -eq "1" ]]; then |
||||
echo "Pulling docker image ${IMAGE}..." |
||||
docker pull ${IMAGE} |
||||
fi |
||||
|
||||
# 更新代码 |
||||
echo "Pulling latest code..." |
||||
git pull |
||||
|
||||
|
||||
# 在 docker 中挂载当前目录编译 |
||||
echo "Building execute in docker..." |
||||
|
||||
docker run --rm \ |
||||
-v ${SHELL_FOLDER}:/data/blotter \ |
||||
-v ${SHELL_FOLDER}/temp:/go/pkg \ |
||||
${IMAGE} \ |
||||
bash -c "go env -w GOPROXY=https://goproxy.cn,direct && cd /data/blotter && echo 'Generating...' && go generate" |
||||
|
||||
echo "Build finished" |
||||
|
||||
docker build -t blotter . |
||||
|
||||
echo "Docker image 'blotter' build finished." |
||||
echo 'Using `docker run --rm --name=backend blotter` to start server.' |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
# 生成代码 |
||||
|
||||
_date=$(date '+%Y-%m-%d %H:%M:%S') |
||||
_branch=$(git rev-parse --abbrev-ref HEAD); _branch="${_branch}@" |
||||
_version=$(git describe --abbrev=0 --tags 2>/dev/null); if [[ -z $_version ]]; then _version="v0.0.0"; fi |
||||
_ldflags="${_branch}${_version} (${_date})" |
||||
|
||||
go build -ldflags "-X 'main._version=${_ldflags}'" |
||||
|
||||
unset _date _branch _version _ldflags |
Loading…
Reference in new issue