You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-08-06 22:32:51 +02:00
Merge branch 'prod' into 'master'
stabilize deployments See merge request geeks-accelerator/oss/saas-starter-kit!17
This commit is contained in:
@ -357,7 +357,18 @@ Access/Secret Keys are required
|
||||
--no-cache skip caching for the docker build
|
||||
--no-push disable pushing release image to remote repository
|
||||
```
|
||||
|
||||
|
||||
* `deploy infrastructure` - Executes a deploy to setup the infrastructure for the deployment environment.
|
||||
|
||||
```bash
|
||||
$ cicd -env [dev|stage|prod] deploy infrastructure [command options]
|
||||
```
|
||||
|
||||
Options:
|
||||
```bash
|
||||
--dry-run print out the deploy details
|
||||
```
|
||||
|
||||
* `deploy service` - Executes a deploy for a single service
|
||||
|
||||
```bash
|
||||
@ -403,6 +414,11 @@ Access/Secret Keys are required
|
||||
|
||||
### Examples
|
||||
|
||||
Setup the infrastructure for _prod_
|
||||
```bash
|
||||
$ cicid --env=prod deploy infrastructure --dry-run=false
|
||||
```
|
||||
|
||||
Build the example service _web-app_
|
||||
```bash
|
||||
$ cicid --env=prod build service --name=web-app --release-tag=testv1 --dry-run=false
|
||||
|
@ -100,7 +100,7 @@ func NewConfig(log *log.Logger, targetEnv Env, awsCredentials devdeploy.AwsCrede
|
||||
remoteUser := gitRemoteUser(modDetails.ProjectRoot)
|
||||
|
||||
// Its a true fork from the origin repo.
|
||||
if remoteUser != "saas-starter-kit" && remoteUser != "geeks-accelerator" {
|
||||
if remoteUser != "oss" {
|
||||
// Replace the prefix 'saas' with the parent directory name, hopefully the gitlab group/username.
|
||||
cfg.ProjectName = filepath.Base(filepath.Dir(cfg.ProjectRoot)) + "-starter-kit"
|
||||
|
||||
@ -613,7 +613,6 @@ func gitRemoteUser(projectRoot string) string {
|
||||
return remoteUser
|
||||
}
|
||||
|
||||
|
||||
// DeployInfrastructureForTargetEnv executes the deploy commands for a target function.
|
||||
func DeployInfrastructureForTargetEnv(log *log.Logger, awsCredentials devdeploy.AwsCredentials, targetEnv Env, dryRun bool) error {
|
||||
|
||||
|
@ -204,7 +204,6 @@ func NewFunction(funcName string, cfg *devdeploy.Config) (*devdeploy.ProjectFunc
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
|
||||
// BuildFunctionForTargetEnv executes the build commands for a target function.
|
||||
func BuildFunctionForTargetEnv(log *log.Logger, awsCredentials devdeploy.AwsCredentials, targetEnv Env, functionName, releaseTag string, dryRun, noCache, noPush bool) error {
|
||||
|
||||
|
@ -45,7 +45,7 @@ type ServiceContext struct {
|
||||
EnableHTTPS bool `validate:"omitempty" example:"false"`
|
||||
EnableElb bool `validate:"omitempty" example:"false"`
|
||||
StaticFilesS3Enable bool `validate:"omitempty" example:"false"`
|
||||
DockerBuildDir string `validate:"omitempty"`
|
||||
DockerBuildDir string `validate:"omitempty"`
|
||||
DockerBuildContext string `validate:"omitempty" example:"."`
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ func (c ServiceContext) BaseUrl() string {
|
||||
// NewService returns the ProjectService for a service that is configured for the target deployment env.
|
||||
func NewService(serviceName string, cfg *devdeploy.Config) (*devdeploy.ProjectService, error) {
|
||||
|
||||
ctx, err := NewServiceContext(serviceName, cfg)
|
||||
ctx, err := NewServiceContext(serviceName, cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -147,11 +147,13 @@ func NewService(serviceName string, cfg *devdeploy.Config) (*devdeploy.ProjectSe
|
||||
CodeDir: filepath.Join(cfg.ProjectRoot, "cmd", serviceName),
|
||||
DockerBuildDir: ctx.DockerBuildDir,
|
||||
DockerBuildContext: ".",
|
||||
EnableHTTPS: ctx.EnableHTTPS,
|
||||
EnableHTTPS: ctx.EnableHTTPS,
|
||||
|
||||
ServiceHostPrimary: ctx.ServiceHostPrimary,
|
||||
ServiceHostNames: ctx.ServiceHostNames,
|
||||
ReleaseTag: ctx.ReleaseTag,
|
||||
ServiceHostNames: ctx.ServiceHostNames,
|
||||
ReleaseTag: ctx.ReleaseTag,
|
||||
|
||||
DockerBuildArgs: make(map[string]string),
|
||||
}
|
||||
|
||||
if srv.DockerBuildDir == "" {
|
||||
@ -362,7 +364,7 @@ func NewService(serviceName string, cfg *devdeploy.Config) (*devdeploy.ProjectSe
|
||||
},
|
||||
Cpu: aws.Int64(128),
|
||||
MemoryReservation: aws.Int64(128),
|
||||
Environment: baseEnvVals(cfg, srv),
|
||||
Environment: baseEnvVals(),
|
||||
HealthCheck: &ecs.HealthCheck{
|
||||
Retries: aws.Int64(3),
|
||||
Command: aws.StringSlice([]string{
|
||||
@ -488,7 +490,7 @@ func NewService(serviceName string, cfg *devdeploy.Config) (*devdeploy.ProjectSe
|
||||
},
|
||||
Cpu: aws.Int64(128),
|
||||
MemoryReservation: aws.Int64(128),
|
||||
Environment: baseEnvVals(cfg, srv),
|
||||
Environment: baseEnvVals(),
|
||||
HealthCheck: &ecs.HealthCheck{
|
||||
Retries: aws.Int64(3),
|
||||
Command: aws.StringSlice([]string{
|
||||
@ -589,6 +591,9 @@ func NewService(serviceName string, cfg *devdeploy.Config) (*devdeploy.ProjectSe
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
srv.DockerBuildArgs["swagInit"] = "1"
|
||||
|
||||
default:
|
||||
return nil, errors.Wrapf(devdeploy.ErrInvalidService,
|
||||
"No service context defined for service '%s'",
|
||||
|
@ -33,7 +33,8 @@ RUN go get github.com/pilu/fresh
|
||||
|
||||
FROM build_base_golang AS dev
|
||||
|
||||
ARG service
|
||||
ARG name
|
||||
ARG code_path=./cmd/${name}
|
||||
ARG commit_ref=-
|
||||
ARG swagInit
|
||||
|
||||
@ -41,9 +42,9 @@ ARG swagInit
|
||||
COPY internal ./internal
|
||||
|
||||
# Copy cmd specific packages.
|
||||
COPY cmd/${service} ./cmd/${service}
|
||||
COPY cmd/${service}/templates /templates
|
||||
#COPY cmd/${service}/static /static
|
||||
COPY ${code_path} ${code_path}
|
||||
COPY ${code_path}/templates /templates
|
||||
#COPY ${code_path}/static /static
|
||||
|
||||
# Copy the global templates.
|
||||
ADD resources/templates/shared /templates/shared
|
||||
@ -51,7 +52,7 @@ ADD configs/fresh-auto-reload.conf /runner.conf
|
||||
|
||||
ENV TEMPLATE_DIR=/templates
|
||||
|
||||
WORKDIR ./cmd/${service}
|
||||
WORKDIR ${code_path}
|
||||
|
||||
ENTRYPOINT ["fresh", "-c", "/runner.conf"]
|
||||
|
||||
@ -76,8 +77,8 @@ ENV TEMPLATE_DIR=/templates
|
||||
ENV SHARED_TEMPLATE_DIR=/templates/shared
|
||||
#ENV STATIC_DIR=/static
|
||||
|
||||
ARG service
|
||||
ENV SERVICE_NAME $service
|
||||
ARG name
|
||||
ENV SERVICE_NAME $name
|
||||
|
||||
ARG env="dev"
|
||||
ENV ENV $env
|
||||
|
@ -17,16 +17,17 @@ RUN go get github.com/pilu/fresh
|
||||
|
||||
FROM build_base_golang AS dev
|
||||
|
||||
ARG service
|
||||
ARG name
|
||||
ARG code_path=./cmd/${name}
|
||||
ARG commit_ref=-
|
||||
|
||||
# Copy shared packages.
|
||||
COPY internal ./internal
|
||||
|
||||
# Copy cmd specific packages.
|
||||
COPY cmd/${service} ./cmd/${service}
|
||||
COPY cmd/${service}/templates /templates
|
||||
COPY cmd/${service}/static /static
|
||||
COPY ${code_path} ${code_path}
|
||||
COPY ${code_path}/templates /templates
|
||||
COPY ${code_path}/static /static
|
||||
|
||||
# Copy the global templates.
|
||||
ADD resources/templates/shared /templates/shared
|
||||
@ -34,7 +35,7 @@ ADD configs/fresh-auto-reload.conf /runner.conf
|
||||
|
||||
ENV TEMPLATE_DIR=/templates
|
||||
|
||||
WORKDIR ./cmd/${service}
|
||||
WORKDIR ${code_path}
|
||||
|
||||
ENTRYPOINT ["fresh", "-c", "/runner.conf"]
|
||||
|
||||
@ -55,8 +56,8 @@ ENV TEMPLATE_DIR=/templates
|
||||
ENV SHARED_TEMPLATE_DIR=/templates/shared
|
||||
ENV STATIC_DIR=/static
|
||||
|
||||
ARG service
|
||||
ENV SERVICE_NAME $service
|
||||
ARG name
|
||||
ENV SERVICE_NAME $name
|
||||
|
||||
ARG env="dev"
|
||||
ENV ENV $env
|
||||
|
@ -807,7 +807,7 @@ func main() {
|
||||
return key
|
||||
}
|
||||
|
||||
res, err := trns.T(key, params...)
|
||||
res, err := trns.T(key, params...)
|
||||
if err != nil {
|
||||
log.Printf("main : Translate.T : Failed to translate %s with '%s' - %+v", trns.Locale(), key, err.Error())
|
||||
return key
|
||||
@ -821,7 +821,7 @@ func main() {
|
||||
return key
|
||||
}
|
||||
|
||||
res, err := trns.C(key, num, digits, param)
|
||||
res, err := trns.C(key, num, digits, param)
|
||||
if err != nil {
|
||||
log.Printf("main : Translate.C : Failed to translate %s with '%s' - %+v", trns.Locale(), key, err.Error())
|
||||
return key
|
||||
@ -829,13 +829,13 @@ func main() {
|
||||
return res
|
||||
},
|
||||
// O creates the ordinal translation for the locale given the 'key', 'num' and 'digit' arguments and param passed in
|
||||
"O": func(ctx context.Context, key string, num float64, digits uint64, param string) string {
|
||||
"O": func(ctx context.Context, key string, num float64, digits uint64, param string) string {
|
||||
trns := webcontext.ContextTranslator(ctx)
|
||||
if trns == nil {
|
||||
return key
|
||||
}
|
||||
|
||||
res, err := trns.O(key, num, digits, param)
|
||||
res, err := trns.O(key, num, digits, param)
|
||||
if err != nil {
|
||||
log.Printf("main : Translate.O : Failed to translate %s with '%s' - %+v", trns.Locale(), key, err.Error())
|
||||
return key
|
||||
@ -850,7 +850,7 @@ func main() {
|
||||
return key
|
||||
}
|
||||
|
||||
res, err := trns.R(key, num1, digits1, num2, digits2, param1, param2)
|
||||
res, err := trns.R(key, num1, digits1, num2, digits2, param1, param2)
|
||||
if err != nil {
|
||||
log.Printf("main : Translate.R : Failed to translate %s with '%s' - %+v", trns.Locale(), key, err.Error())
|
||||
return key
|
||||
|
4
go.mod
4
go.mod
@ -41,7 +41,7 @@ require (
|
||||
github.com/tinylib/msgp v1.1.0 // indirect
|
||||
github.com/urfave/cli v1.21.0
|
||||
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
|
||||
gitlab.com/geeks-accelerator/oss/devops v1.0.14
|
||||
gitlab.com/geeks-accelerator/oss/devops v1.0.15
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7
|
||||
golang.org/x/tools v0.0.0-20190807223507-b346f7fd45de // indirect
|
||||
@ -51,3 +51,5 @@ require (
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||
gotest.tools v2.2.0+incompatible // indirect
|
||||
)
|
||||
|
||||
// replace gitlab.com/geeks-accelerator/oss/devops => ../devops
|
||||
|
2
go.sum
2
go.sum
@ -221,6 +221,8 @@ gitlab.com/geeks-accelerator/oss/devops v1.0.13 h1:Wnf+vXPP8Ps4tSVdbk/vgl1rHaAEL
|
||||
gitlab.com/geeks-accelerator/oss/devops v1.0.13/go.mod h1:xr+rhNSDXrEh0A6bkBPnfMiRIou3OiPZK0oD5h9GAAM=
|
||||
gitlab.com/geeks-accelerator/oss/devops v1.0.14 h1:jNLi69UAH44+FkixN/rtS7qobsSFvxwQ+g8NgVOwFt0=
|
||||
gitlab.com/geeks-accelerator/oss/devops v1.0.14/go.mod h1:xr+rhNSDXrEh0A6bkBPnfMiRIou3OiPZK0oD5h9GAAM=
|
||||
gitlab.com/geeks-accelerator/oss/devops v1.0.15 h1:JEadFDCPVqKSNFLFBNmqm94SU0AhO0niRRViUcwMxBc=
|
||||
gitlab.com/geeks-accelerator/oss/devops v1.0.15/go.mod h1:xr+rhNSDXrEh0A6bkBPnfMiRIou3OiPZK0oD5h9GAAM=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
|
Reference in New Issue
Block a user