updating build
remove exists function
This commit is contained in:
parent
64d066ba4b
commit
8272d2d934
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@ -0,0 +1,6 @@
|
||||
build.sh
|
||||
Dockerfile
|
||||
.git
|
||||
.idea
|
||||
.gitignore
|
||||
.dockerignore
|
15
Dockerfile
15
Dockerfile
@ -1,16 +1,17 @@
|
||||
FROM golang as builder
|
||||
FROM golang:1.12.6-alpine3.10 as builder
|
||||
RUN apk add --update --no-cache ca-certificates git tzdata
|
||||
WORKDIR /tmp/dnsupdater
|
||||
COPY . .
|
||||
RUN go get .
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY ./ ./
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o dnsupdater .
|
||||
|
||||
FROM busybox:glibc
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||
COPY --from=builder /tmp/dnsupdater/dnsupdater .
|
||||
|
||||
RUN mkdir -p /var/spool/cron/crontabs /var/log
|
||||
COPY entry.sh /entry.sh
|
||||
RUN touch /var/log/cron.log
|
||||
WORKDIR "/"
|
||||
|
||||
COPY entry.sh /entry.sh
|
||||
COPY --from=builder /tmp/dnsupdater/dnsupdater .
|
||||
ENTRYPOINT ["/entry.sh"]
|
||||
|
1
build.sh
1
build.sh
@ -4,4 +4,5 @@ docker build --rm -t llehouerou/dnsupdater:latest .
|
||||
rc=$?
|
||||
if [[ ${rc} == 0 ]]; then
|
||||
docker push llehouerou/dnsupdater
|
||||
ssh srv03 'docker pull llehouerou/dnsupdater; cd docker/conf/goservices; docker-compose up -d --remove-orphans'
|
||||
fi
|
20
main.go
20
main.go
@ -77,15 +77,14 @@ func before(c *cli.Context) error {
|
||||
log.SetLevel(log.InfoLevel)
|
||||
|
||||
configPath = path.Join(c.String("config"), "conf.json")
|
||||
if confPathExists, _ := exists(configPath); !confPathExists {
|
||||
return fmt.Errorf("config file does not exist : %s", configPath)
|
||||
file, err := os.Open(configPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error while opening config file: %v", err)
|
||||
}
|
||||
|
||||
file, _ := os.Open(configPath)
|
||||
defer file.Close()
|
||||
decoder := json.NewDecoder(file)
|
||||
configuration = &Configuration{}
|
||||
err := decoder.Decode(configuration)
|
||||
err = decoder.Decode(configuration)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -264,14 +263,3 @@ func GetOutboundIP() (string, error) {
|
||||
}
|
||||
return matches[1], nil
|
||||
}
|
||||
|
||||
func exists(path string) (bool, error) {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
}
|
||||
return true, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user