update code

This commit is contained in:
lychang
2023-12-28 21:56:01 +08:00
parent 6eed4da502
commit b5ed03d89f
4 changed files with 49 additions and 16 deletions

39
.gitlab-ci.yaml Normal file
View File

@@ -0,0 +1,39 @@
stages:
- generate_image
- deploy
variables:
BUILD_NAME: "go/ddns"
SERVICE_NAME: "ddns"
IMAGE_TAG: "latest"
generate_image_dev:
variables:
IMAGE_TAG: dev
stage: generate_image
image: docker:20.10.2
script:
- docker build -t $BUILD_NAME:$IMAGE_TAG .
tags:
- '001'
only:
- dev
except:
- triggers
deploy_dev:
stage: deploy
image: docker:20.10.2
script:
- CONTAINER_NAME=$(docker ps -aq --filter name=$SERVICE_NAME)
- echo $CONTAINER_NAME
- if [[ -n "$CONTAINER_NAME" ]]; then
docker rm -f $CONTAINER_NAME;
fi
- docker run -d --name $SERVICE_NAME $BUILD_NAME:$IMAGE_TAG
tags:
- '001'
only:
- dev
except:
- triggers

View File

@@ -1,7 +1,15 @@
FROM golang:latest as builder
ENV GOPROXY https://goproxy.io,direct
WORKDIR /app
COPY . .
RUN go build -o ddns
FROM alpine:latest FROM alpine:latest
MAINTAINER Eirf MAINTAINER Eirf
ENV VERSION 1.0 ENV VERSION 1.0
WORKDIR /app WORKDIR /app
COPY . . COPY --from=builder /app/ddns /app/ddns
CMD ["/app/ddns"] CMD ["/app/ddns"]

View File

@@ -1,14 +0,0 @@
FROM golang:builder as builder
WORKDIR /app
COPY . .
RUN go build -o ddns
FROM golang:runner
MAINTAINER Eirf
ENV VERSION 1.0
WORKDIR /app
COPY --from=builder /app/ddns /app/ddns
CMD ["/app/ddns"]

2
go.mod
View File

@@ -3,6 +3,7 @@ module client
go 1.17 go 1.17
require ( require (
github.com/PuerkitoBio/goquery v1.8.0
github.com/alibabacloud-go/alidns-20150109/v2 v2.0.1 github.com/alibabacloud-go/alidns-20150109/v2 v2.0.1
github.com/alibabacloud-go/darabonba-env v1.0.0 github.com/alibabacloud-go/darabonba-env v1.0.0
github.com/alibabacloud-go/darabonba-openapi v0.1.1 github.com/alibabacloud-go/darabonba-openapi v0.1.1
@@ -12,7 +13,6 @@ require (
) )
require ( require (
github.com/PuerkitoBio/goquery v1.8.0 // indirect
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect
github.com/alibabacloud-go/openapi-util v0.0.6 // indirect github.com/alibabacloud-go/openapi-util v0.0.6 // indirect