You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-08-08 22:36:41 +02:00
fix docker-compose up - webapp required sender email to be set
This commit is contained in:
@@ -32,23 +32,27 @@ RUN go mod download
|
|||||||
|
|
||||||
FROM build_base_golang AS builder
|
FROM build_base_golang AS builder
|
||||||
|
|
||||||
|
ARG service
|
||||||
|
ARG commit_ref=-
|
||||||
|
|
||||||
# Copy shared packages.
|
# Copy shared packages.
|
||||||
COPY internal ./internal
|
COPY internal ./internal
|
||||||
|
|
||||||
# Copy cmd specific packages.
|
# Copy cmd specific packages.
|
||||||
COPY cmd/web-api ./cmd/web-api
|
COPY cmd/${service} ./cmd/web-api
|
||||||
COPY cmd/web-api/templates /templates
|
COPY cmd/${service}/templates /templates
|
||||||
#COPY cmd/web-api/static /static
|
#COPY cmd/${service}/static /static
|
||||||
|
|
||||||
# Copy the global templates.
|
# Copy the global templates.
|
||||||
ADD resources/templates/shared /templates/shared
|
ADD resources/templates/shared /templates/shared
|
||||||
|
|
||||||
WORKDIR ./cmd/web-api
|
WORKDIR ./cmd/${service}
|
||||||
|
|
||||||
# Update the API documentation.
|
# Update the API documentation.
|
||||||
RUN swag init
|
# Disabled for the moment as it takes forever to run, rely on manual execution.
|
||||||
|
#RUN swag init
|
||||||
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /gosrv .
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.build=${commit_ref}" -a -installsuffix nocgo -o /gosrv .
|
||||||
|
|
||||||
FROM alpine:3.9
|
FROM alpine:3.9
|
||||||
|
|
||||||
|
@@ -16,20 +16,23 @@ RUN go mod download
|
|||||||
|
|
||||||
FROM build_base_golang AS builder
|
FROM build_base_golang AS builder
|
||||||
|
|
||||||
|
ARG service
|
||||||
|
ARG commit_ref=-
|
||||||
|
|
||||||
# Copy shared packages.
|
# Copy shared packages.
|
||||||
COPY internal ./internal
|
COPY internal ./internal
|
||||||
|
|
||||||
# Copy cmd specific packages.
|
# Copy cmd specific packages.
|
||||||
COPY cmd/web-app ./cmd/web-app
|
COPY cmd/${service} ./cmd/web-app
|
||||||
COPY cmd/web-app/templates /templates
|
COPY cmd/${service}/templates /templates
|
||||||
COPY cmd/web-app/static /static
|
COPY cmd/${service}/static /static
|
||||||
|
|
||||||
# Copy the global templates.
|
# Copy the global templates.
|
||||||
ADD resources/templates/shared /templates/shared
|
ADD resources/templates/shared /templates/shared
|
||||||
|
|
||||||
WORKDIR ./cmd/web-app
|
WORKDIR ./cmd/${service}
|
||||||
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /gosrv .
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.build=${commit_ref}" -a -installsuffix nocgo -o /gosrv .
|
||||||
|
|
||||||
FROM alpine:3.9
|
FROM alpine:3.9
|
||||||
|
|
||||||
|
@@ -102,7 +102,7 @@ func main() {
|
|||||||
WebApiBaseUrl string `default:"http://127.0.0.1:3001" envconfig:"WEB_API_BASE_URL" example:"http://api.eproc.tech"`
|
WebApiBaseUrl string `default:"http://127.0.0.1:3001" envconfig:"WEB_API_BASE_URL" example:"http://api.eproc.tech"`
|
||||||
SessionKey string `default:"" envconfig:"SESSION_KEY"`
|
SessionKey string `default:"" envconfig:"SESSION_KEY"`
|
||||||
SessionName string `default:"" envconfig:"SESSION_NAME"`
|
SessionName string `default:"" envconfig:"SESSION_NAME"`
|
||||||
EmailSender string `default:"" envconfig:"EMAIL_SENDER"`
|
EmailSender string `default:"test@eproc.tech" envconfig:"EMAIL_SENDER"`
|
||||||
DebugHost string `default:"0.0.0.0:4000" envconfig:"DEBUG_HOST"`
|
DebugHost string `default:"0.0.0.0:4000" envconfig:"DEBUG_HOST"`
|
||||||
ShutdownTimeout time.Duration `default:"5s" envconfig:"SHUTDOWN_TIMEOUT"`
|
ShutdownTimeout time.Duration `default:"5s" envconfig:"SHUTDOWN_TIMEOUT"`
|
||||||
}
|
}
|
||||||
|
@@ -58,13 +58,14 @@ services:
|
|||||||
- DD_TAGS=source:docker env:dev
|
- DD_TAGS=source:docker env:dev
|
||||||
- DD_DOGSTATSD_ORIGIN_DETECTION=true
|
- DD_DOGSTATSD_ORIGIN_DETECTION=true
|
||||||
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
|
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
|
||||||
#- ECS_FARGATE=false
|
|
||||||
- DD_EXPVAR=service_name=web-app env=dev url=http://web-app:4000/debug/vars|service_name=web-api env=dev url=http://web-api:4001/debug/vars
|
- DD_EXPVAR=service_name=web-app env=dev url=http://web-app:4000/debug/vars|service_name=web-api env=dev url=http://web-api:4001/debug/vars
|
||||||
web-app:
|
web-app:
|
||||||
image: example-project/web-app:latest
|
image: example-project/web-app:latest
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: cmd/web-app/Dockerfile
|
dockerfile: cmd/web-app/Dockerfile
|
||||||
|
args:
|
||||||
|
service: 'web-app'
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000 # WEB APP
|
- 3000:3000 # WEB APP
|
||||||
- 4000:4000 # DEBUG API
|
- 4000:4000 # DEBUG API
|
||||||
@@ -83,10 +84,11 @@ services:
|
|||||||
- WEB_APP_APP_BASE_URL=http://127.0.0.1:3000
|
- WEB_APP_APP_BASE_URL=http://127.0.0.1:3000
|
||||||
- WEB_API_APP_DEBUG_HOST=:4000
|
- WEB_API_APP_DEBUG_HOST=:4000
|
||||||
- WEB_APP_REDIS_HOST=redis:6379
|
- WEB_APP_REDIS_HOST=redis:6379
|
||||||
- WEB_APP_DB_HOST=postgres:5433
|
- WEB_APP_DB_HOST=postgres:5432
|
||||||
- WEB_APP_DB_USER=postgres
|
- WEB_APP_DB_USER=postgres
|
||||||
- WEB_APP_DB_PASS=postgres
|
- WEB_APP_DB_PASS=postgres
|
||||||
- WEB_APP_DB_DATABASE=shared
|
- WEB_APP_DB_DATABASE=shared
|
||||||
|
- WEB_APP_DB_DISABLE_TLS=true
|
||||||
- DD_TRACE_AGENT_HOSTNAME=datadog
|
- DD_TRACE_AGENT_HOSTNAME=datadog
|
||||||
- DD_TRACE_AGENT_PORT=8126
|
- DD_TRACE_AGENT_PORT=8126
|
||||||
- DD_SERVICE_NAME=web-app
|
- DD_SERVICE_NAME=web-app
|
||||||
@@ -98,6 +100,8 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: cmd/web-api/Dockerfile
|
dockerfile: cmd/web-api/Dockerfile
|
||||||
|
args:
|
||||||
|
service: 'web-api'
|
||||||
ports:
|
ports:
|
||||||
- 3001:3001 # WEB API
|
- 3001:3001 # WEB API
|
||||||
- 4001:4001 # DEBUG API
|
- 4001:4001 # DEBUG API
|
||||||
@@ -116,10 +120,11 @@ services:
|
|||||||
- WEB_API_APP_BASE_URL=http://127.0.0.1:3001
|
- WEB_API_APP_BASE_URL=http://127.0.0.1:3001
|
||||||
- WEB_API_APP_DEBUG_HOST=:4001
|
- WEB_API_APP_DEBUG_HOST=:4001
|
||||||
- WEB_API_REDIS_HOST=redis:6379
|
- WEB_API_REDIS_HOST=redis:6379
|
||||||
- WEB_API_DB_HOST=postgres:5433
|
- WEB_API_DB_HOST=postgres:5432
|
||||||
- WEB_API_DB_USER=postgres
|
- WEB_API_DB_USER=postgres
|
||||||
- WEB_API_DB_PASS=postgres
|
- WEB_API_DB_PASS=postgres
|
||||||
- WEB_API_DB_DATABASE=shared
|
- WEB_API_DB_DATABASE=shared
|
||||||
|
- WEB_API_DB_DISABLE_TLS=true
|
||||||
- DD_TRACE_AGENT_HOSTNAME=datadog
|
- DD_TRACE_AGENT_HOSTNAME=datadog
|
||||||
- DD_TRACE_AGENT_PORT=8126
|
- DD_TRACE_AGENT_PORT=8126
|
||||||
- DD_SERVICE_NAME=web-app
|
- DD_SERVICE_NAME=web-app
|
||||||
|
@@ -75,8 +75,7 @@ func (di *DirectoryIterator) UploadObject() s3manager.BatchUploadObject {
|
|||||||
acl = aws.String(di.acl)
|
acl = aws.String(di.acl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffer, contentType, rerr := readFile(f)
|
||||||
buffer, contentType, rerr := readFile(f)
|
|
||||||
|
|
||||||
nextPath, _ := filepath.Rel(di.dir, di.next.path)
|
nextPath, _ := filepath.Rel(di.dir, di.next.path)
|
||||||
|
|
||||||
|
@@ -29,6 +29,7 @@ type ServiceBuildFlags struct {
|
|||||||
ProjectRoot string `validate:"omitempty" example:"."`
|
ProjectRoot string `validate:"omitempty" example:"."`
|
||||||
ProjectName string ` validate:"omitempty" example:"example-project"`
|
ProjectName string ` validate:"omitempty" example:"example-project"`
|
||||||
DockerFile string `validate:"omitempty" example:"./cmd/web-api/Dockerfile"`
|
DockerFile string `validate:"omitempty" example:"./cmd/web-api/Dockerfile"`
|
||||||
|
CommitRef string `validate:"omitempty" example:"master@1ecfd275"`
|
||||||
NoCache bool `validate:"omitempty" example:"false"`
|
NoCache bool `validate:"omitempty" example:"false"`
|
||||||
NoPush bool `validate:"omitempty" example:"false"`
|
NoPush bool `validate:"omitempty" example:"false"`
|
||||||
}
|
}
|
||||||
@@ -41,8 +42,9 @@ type serviceBuildRequest struct {
|
|||||||
EcrRepository *ecr.CreateRepositoryInput
|
EcrRepository *ecr.CreateRepositoryInput
|
||||||
EcrRepositoryMaxImages int `validate:"omitempty"`
|
EcrRepositoryMaxImages int `validate:"omitempty"`
|
||||||
|
|
||||||
NoCache bool `validate:"omitempty"`
|
CommitRef string `validate:"omitempty"`
|
||||||
NoPush bool `validate:"omitempty"`
|
NoCache bool `validate:"omitempty"`
|
||||||
|
NoPush bool `validate:"omitempty"`
|
||||||
|
|
||||||
flags ServiceBuildFlags
|
flags ServiceBuildFlags
|
||||||
}
|
}
|
||||||
@@ -79,8 +81,9 @@ func NewServiceBuildRequest(log *log.Logger, flags ServiceBuildFlags) (*serviceB
|
|||||||
req = serviceBuildRequest{
|
req = serviceBuildRequest{
|
||||||
serviceRequest: sr,
|
serviceRequest: sr,
|
||||||
|
|
||||||
NoCache: flags.NoCache,
|
CommitRef: flags.CommitRef,
|
||||||
NoPush: flags.NoPush,
|
NoCache: flags.NoCache,
|
||||||
|
NoPush: flags.NoPush,
|
||||||
|
|
||||||
flags: flags,
|
flags: flags,
|
||||||
}
|
}
|
||||||
@@ -100,6 +103,19 @@ func NewServiceBuildRequest(log *log.Logger, flags ServiceBuildFlags) (*serviceB
|
|||||||
req.EcrRepositoryMaxImages = defaultAwsRegistryMaxImages
|
req.EcrRepositoryMaxImages = defaultAwsRegistryMaxImages
|
||||||
log.Printf("\t\t\tSet ECR Regsistry Max Images to '%d'.", req.EcrRepositoryMaxImages)
|
log.Printf("\t\t\tSet ECR Regsistry Max Images to '%d'.", req.EcrRepositoryMaxImages)
|
||||||
|
|
||||||
|
// Get the default commit ref.
|
||||||
|
if req.CommitRef == "" {
|
||||||
|
if ev := os.Getenv("CI_COMMIT_TAG"); ev != "" {
|
||||||
|
req.CommitRef = "tag-" + ev
|
||||||
|
} else if ev := os.Getenv("CI_COMMIT_REF_NAME"); ev != "" {
|
||||||
|
req.CommitRef = "branch-" + ev
|
||||||
|
}
|
||||||
|
|
||||||
|
if ev := os.Getenv("CI_COMMIT_SHORT_SHA"); ev != "" {
|
||||||
|
req.CommitRef = req.CommitRef + "@" + ev
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &req, nil
|
return &req, nil
|
||||||
@@ -315,6 +331,7 @@ func ServiceBuild(log *log.Logger, req *serviceBuildRequest) error {
|
|||||||
"--file=" + dockerFile,
|
"--file=" + dockerFile,
|
||||||
"--build-arg", "service=" + req.ServiceName,
|
"--build-arg", "service=" + req.ServiceName,
|
||||||
"--build-arg", "env=" + req.Env,
|
"--build-arg", "env=" + req.Env,
|
||||||
|
"--build-arg", "commit_ref=" + req.CommitRef,
|
||||||
"-t", req.ReleaseImage,
|
"-t", req.ReleaseImage,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3329,7 +3329,7 @@ func ServiceDeploy(log *log.Logger, req *serviceDeployRequest) error {
|
|||||||
|
|
||||||
staticDir := filepath.Join(req.ServiceDir, "static")
|
staticDir := filepath.Join(req.ServiceDir, "static")
|
||||||
|
|
||||||
if _, err := os.Stat(staticDir); err != nil {
|
if _, err := os.Stat(staticDir); err != nil {
|
||||||
return errors.Wrapf(err, "Static directory '%s' does not exist.", staticDir)
|
return errors.Wrapf(err, "Static directory '%s' does not exist.", staticDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user