1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-08-08 22:36:41 +02:00

updated devops tool to use scratch image for cache

This commit is contained in:
Lee Brown
2019-08-06 19:40:11 -08:00
parent 17ed09708c
commit 3bb152a146
3 changed files with 17 additions and 6 deletions

View File

@ -1,4 +1,4 @@
FROM golang:1.12.6-alpine3.9
FROM golang:1.12.6-alpine3.9 AS builder
LABEL maintainer="lee@geeksinthewoods.com"
@ -19,6 +19,10 @@ COPY tools/devops ./tools/devops
WORKDIR ./tools/devops
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /devops .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /go/bin/devops .
ENTRYPOINT ["/devops"]
FROM scratch
COPY --from=builder /go/bin/devops /go/bin/devops
ENTRYPOINT ["/go/bin/devops"]

View File

@ -291,7 +291,7 @@ func ServiceBuild(log *log.Logger, req *serviceBuildRequest) error {
buildBaseImage = req.ProjectName + ":" + req.Env + "-" + req.ServiceName + "-" + buildBaseImageTag
}
cmds = append(cmds, []string{"docker", "pull", buildBaseImageTag})
cmds = append(cmds, []string{"docker", "pull", buildBaseImage})
cmds = append(cmds, []string{
"docker", "build",
@ -337,7 +337,14 @@ func ServiceBuild(log *log.Logger, req *serviceBuildRequest) error {
}
for _, cmd := range cmds {
log.Printf("\t\t%s\n", strings.Join(cmd, " "))
var logCmd string
if len(cmd) >= 2 && cmd[1] == "login" {
logCmd = strings.Join(cmd[0:2], " ")
} else {
logCmd = strings.Join(cmd, " ")
}
log.Printf("\t\t%s\n", logCmd)
err = execCmds(log, req.ProjectRoot, cmd)
if err != nil {

View File

@ -20,5 +20,5 @@ if [[ $doPush == 1 ]]; then
docker push ${releaseImg}
fi
docker run --rm --entrypoint=cat ${releaseImg} /devops > devops
docker run --rm --entrypoint=cat ${releaseImg} /go/bin/devops > devops
chmod +x devops