1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-06-29 00:52:03 +02:00

fixing build cache target name

This commit is contained in:
Lee Brown
2019-08-06 12:29:00 -08:00
parent 7e5cc45c73
commit ae1e1c0556
5 changed files with 41 additions and 11 deletions

View File

@ -32,7 +32,7 @@ cache:
.build_tmpl: &build_tmpl .build_tmpl: &build_tmpl
<<: *job_tmpl <<: *job_tmpl
script: script:
- 'EMAIL_SENDER=$EMAIL_SENDER devops build -service=${SERVICE} -project=${PROJECT_NAME} -env=${TARGET_ENV}' - 'devops build -service=${SERVICE} -project=${PROJECT_NAME} -env=${TARGET_ENV}'
.deploy_tmpl: &deploy_tmpl .deploy_tmpl: &deploy_tmpl
<<: *job_tmpl <<: *job_tmpl

View File

@ -3,6 +3,7 @@ package handlers
import ( import (
"context" "context"
"net/http" "net/http"
"os"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web" "geeks-accelerator/oss/saas-starter-kit/internal/platform/web"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
@ -33,13 +34,27 @@ func (c *Check) Health(ctx context.Context, w http.ResponseWriter, r *http.Reque
return errors.Wrap(err, "Redis failed") return errors.Wrap(err, "Redis failed")
} }
status := struct { data := struct {
Status string `json:"status"` Status string `json:"status"`
CiCommitRefName string `json:"ci-commit-ref-name,omitempty"`
CiCommitRefSlug string `json:"ci-commit-ref-slug,omitempty"`
CiCommitSha string `json:"ci-commit-sha,omitempty"`
CiCommitTag string `json:"ci-commit-tag,omitempty"`
CiCommitTitle string `json:"ci-commit-title,omitempty"`
CiJobId string `json:"ci-commit-job-id,omitempty"`
CiPipelineId string `json:"ci-commit-pipeline-id,omitempty"`
}{ }{
Status: "ok", Status: "ok",
CiCommitRefName: os.Getenv("CI_COMMIT_REF_NAME"),
CiCommitRefSlug: os.Getenv("CI_COMMIT_REF_SLUG"),
CiCommitSha: os.Getenv("CI_COMMIT_SHA"),
CiCommitTag: os.Getenv("CI_COMMIT_TAG"),
CiCommitTitle: os.Getenv("CI_COMMIT_TITLE"),
CiJobId : os.Getenv("CI_COMMIT_JOB_ID"),
CiPipelineId: os.Getenv("CI_COMMIT_PIPELINE_ID"),
} }
return web.RespondJson(ctx, w, status, http.StatusOK) return web.RespondJson(ctx, w, data, http.StatusOK)
} }
// Ping validates the service is ready to accept requests. // Ping validates the service is ready to accept requests.

View File

@ -3,6 +3,7 @@ package handlers
import ( import (
"context" "context"
"net/http" "net/http"
"os"
"geeks-accelerator/oss/saas-starter-kit/internal/platform/web" "geeks-accelerator/oss/saas-starter-kit/internal/platform/web"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
@ -14,7 +15,6 @@ import (
type Check struct { type Check struct {
MasterDB *sqlx.DB MasterDB *sqlx.DB
Redis *redis.Client Redis *redis.Client
Renderer web.Renderer
// ADD OTHER STATE LIKE THE LOGGER IF NEEDED. // ADD OTHER STATE LIKE THE LOGGER IF NEEDED.
} }
@ -34,8 +34,24 @@ func (c *Check) Health(ctx context.Context, w http.ResponseWriter, r *http.Reque
return errors.Wrap(err, "Redis failed") return errors.Wrap(err, "Redis failed")
} }
data := map[string]interface{}{ data := struct {
"Status": "ok", Status string `json:"status"`
CiCommitRefName string `json:"ci-commit-ref-name,omitempty"`
CiCommitRefSlug string `json:"ci-commit-ref-slug,omitempty"`
CiCommitSha string `json:"ci-commit-sha,omitempty"`
CiCommitTag string `json:"ci-commit-tag,omitempty"`
CiCommitTitle string `json:"ci-commit-title,omitempty"`
CiJobId string `json:"ci-commit-job-id,omitempty"`
CiPipelineId string `json:"ci-commit-pipeline-id,omitempty"`
}{
Status: "ok",
CiCommitRefName: os.Getenv("CI_COMMIT_REF_NAME"),
CiCommitRefSlug: os.Getenv("CI_COMMIT_REF_SLUG"),
CiCommitSha: os.Getenv("CI_COMMIT_SHA"),
CiCommitTag: os.Getenv("CI_COMMIT_TAG"),
CiCommitTitle: os.Getenv("CI_COMMIT_TITLE"),
CiJobId : os.Getenv("CI_COMMIT_JOB_ID"),
CiPipelineId: os.Getenv("CI_COMMIT_PIPELINE_ID"),
} }
return web.RespondJson(ctx, w, data, http.StatusOK) return web.RespondJson(ctx, w, data, http.StatusOK)

View File

@ -163,7 +163,6 @@ func APP(shutdown chan os.Signal, log *log.Logger, env webcontext.Env, staticDir
check := Check{ check := Check{
MasterDB: masterDB, MasterDB: masterDB,
Redis: redis, Redis: redis,
Renderer: renderer,
} }
app.Handle("GET", "/v1/health", check.Health) app.Handle("GET", "/v1/health", check.Health)

View File

@ -199,6 +199,9 @@ func ServiceBuild(log *log.Logger, req *serviceBuildRequest) error {
return errors.Wrapf(err, "Failed parse relative path for %s from %s", req.DockerFile, req.ProjectRoot) return errors.Wrapf(err, "Failed parse relative path for %s from %s", req.DockerFile, req.ProjectRoot)
} }
// Name of the first build stage declared in the docckerFile.
var buildStageName string
// When the dockerFile is multistage, caching can be applied. Scan the dockerFile for the first stage. // When the dockerFile is multistage, caching can be applied. Scan the dockerFile for the first stage.
// FROM golang:1.12.6-alpine3.9 AS build_base // FROM golang:1.12.6-alpine3.9 AS build_base
var buildBaseImageTag string var buildBaseImageTag string
@ -213,9 +216,6 @@ func ServiceBuild(log *log.Logger, req *serviceBuildRequest) error {
// any changes to the lines associated with the first stage force cache to be reset. // any changes to the lines associated with the first stage force cache to be reset.
var stageLines []string var stageLines []string
// Name of the first build stage declared in the docckerFile.
var buildStageName string
// Loop through all the lines in the Dockerfile searching for the lines associated with the first build stage. // Loop through all the lines in the Dockerfile searching for the lines associated with the first build stage.
scanner := bufio.NewScanner(file) scanner := bufio.NewScanner(file)
for scanner.Scan() { for scanner.Scan() {
@ -299,7 +299,7 @@ func ServiceBuild(log *log.Logger, req *serviceBuildRequest) error {
"--build-arg", "service=" + req.ServiceName, "--build-arg", "service=" + req.ServiceName,
"--build-arg", "env=" + req.Env, "--build-arg", "env=" + req.Env,
"-t", buildBaseImageTag, "-t", buildBaseImageTag,
"--target", "build_base", "--target", buildStageName,
".", ".",
}) })