项目中的dockerfile
FROM golang:1.16 AS builder
COPY . /src
WORKDIR /src
RUN GOPROXY=https://goproxy.cn make build
from alpine:latest
#时区
USER root
COPY --from=builder /src/bin /app
WORKDIR /app
RUN mkdir -p /tmp/ds
EXPOSE 8000
EXPOSE 9000
VOLUME /data/conf
VOLUME /tmp/ds
CMD ["./gospider", "-conf", "/data/conf"]
.gitlab-ci.yml
stages:
- build
- test
- run
build-ss:
stage: build
image: docker:latest
script:
- docker build -t gospider .
test-ss:
stage: test
script:
- echo "test"
run-ss:
image: docker:latest
stage: run
script:
- docker stop g2 ||echo 0
- docker rm g2 ||echo 0
- docker run -e TZ="Asia/Shanghai" --rm -itd --name g2 -p 8009:8000 -v /tmp/ds:/tmp/ds -v /app/config.yaml:/data/conf/config.yaml gospider