Skip to content

Commit

Permalink
feat(docker): adapt the version of the docker image to the runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
solrac97gr committed Dec 7, 2024
1 parent 53af658 commit 8874c6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (f *Files) CreateFilesStructure(githubName string, projectName string, goVe
f.CreateFile((projectName + "/cmd/http/main.go"), templates.NewMainTemplate(githubName, projectName, subAppName))
f.CreateFile(projectName+"/pkg/server/super_server.go", templates.NewSuperServerTemplate(projectName))
f.CreateFile(projectName+"/Makefile", templates.NewMakefileTemplate(projectName))
f.CreateFile(projectName+"/infrastructure/docker/Dockerfile", templates.NewDockerfileTemplate())
f.CreateFile(projectName+"/infrastructure/docker/Dockerfile", templates.NewDockerfileTemplate(goVersion))
f.CreateFile(projectName+"/docker-compose.yaml", templates.NewDockerComposeTemplate())
f.CreateFile(projectName+"/.env.example", templates.NewEnvTemplate())
f.CreateFile(projectName+"./.gitignore", templates.NewGitIgnoreTemplate())
Expand Down
8 changes: 5 additions & 3 deletions templates/docker.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package templates

import "fmt"

var DockerfileTemplate = `# Build stage
FROM golang:1.23-alpine AS builder
FROM golang:%s-alpine AS builder
# Set working directory
WORKDIR /app
Expand Down Expand Up @@ -32,6 +34,6 @@ COPY --from=builder /app/main .
# Command to run the application
CMD ["./main"]`

func NewDockerfileTemplate() string {
return DockerfileTemplate
func NewDockerfileTemplate(version string) string {
return fmt.Sprintf(DockerfileTemplate, version)
}

0 comments on commit 8874c6b

Please sign in to comment.