initial commit
This commit is contained in:
		
						commit
						93eea1fad0
					
				
							
								
								
									
										7
									
								
								cookiecutter.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								cookiecutter.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| { | ||||
|     "project_name": "Go Project", | ||||
|     "project_slug": "{{ cookiecutter.project_name.lower().replace(' ', '-')}}", | ||||
|     "mod_name": "{{ cookiecutter.project_name.lower().replace(' ', '').replace('-', '')}}", | ||||
|     "docker_username": "djeeberjr", | ||||
|     "mod_base": "git.kapelle.org/niklas/{{cookiecutter.project_slug}}" | ||||
| } | ||||
							
								
								
									
										9
									
								
								hooks/post_gen_project.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								hooks/post_gen_project.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| #!/usr/bin/env sh | ||||
| 
 | ||||
| set -e  | ||||
| 
 | ||||
| git init | ||||
| 
 | ||||
| go mod init {{cookiecutter.mod_base}} | ||||
| 
 | ||||
| go mod tidy | ||||
							
								
								
									
										1
									
								
								{{cookiecutter.project_slug}}/.dockerignore
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								{{cookiecutter.project_slug}}/.dockerignore
									
									
									
									
									
										Symbolic link
									
								
							| @ -0,0 +1 @@ | ||||
| .gitignore | ||||
							
								
								
									
										1
									
								
								{{cookiecutter.project_slug}}/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								{{cookiecutter.project_slug}}/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| /build | ||||
							
								
								
									
										22
									
								
								{{cookiecutter.project_slug}}/Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								{{cookiecutter.project_slug}}/Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| FROM --platform=$BUILDPLATFORM golang:1.21-alpine as build | ||||
| 
 | ||||
| ADD . /app | ||||
| WORKDIR /app | ||||
| 
 | ||||
| ARG TARGETARCH | ||||
| ARG TARGETOS | ||||
| 
 | ||||
| RUN apk add --no-cache make | ||||
| RUN make build BUILD_ARCH="$TARGETARCH" BUILD_OS="$TARGETOS" | ||||
| 
 | ||||
| FROM --platform=$TARGETPLATFORM alpine:latest | ||||
| 
 | ||||
| RUN apk add --no-cache make ca-certificates | ||||
| 
 | ||||
| WORKDIR /data | ||||
| COPY --from=build /app/build/{{cookiecutter.project_slug}} /app/{{cookiecutter.project_slug}} | ||||
| 
 | ||||
| EXPOSE 3000 | ||||
| VOLUME [ "/data" ] | ||||
| 
 | ||||
| CMD [ "/app/{{cookiecutter.project_slug}}" ]       | ||||
							
								
								
									
										21
									
								
								{{cookiecutter.project_slug}}/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								{{cookiecutter.project_slug}}/Makefile
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| BINARY = {{cookiecutter.project_slug}} | ||||
| BUILD_DIR = build | ||||
| BUILD_ARCH = $(shell go env GOARCH) | ||||
| BUILD_OS = $(shell go env GOOS) | ||||
| 
 | ||||
| .PHONY: all | ||||
| all: clean build | ||||
| 
 | ||||
| .PHONY:build | ||||
| build: $(BUILD_DIR)/$(BINARY) | ||||
| 
 | ||||
| $(BUILD_DIR)/$(BINARY): | ||||
| 	GOARCH=$(BUILD_ARCH) GOOS=$(BUILD_OS) go build -o $(BUILD_DIR)/$(BINARY) cmd/{{cookiecutter.project_slug}}.go | ||||
| 
 | ||||
| .PHONY:clean | ||||
| clean: | ||||
| 	rm -rf $(BUILD_DIR) | ||||
| 
 | ||||
| .PHONY: docker | ||||
| docker: | ||||
| 	docker buildx build --platform linux/arm64,linux/amd64,linux/arm/v7,linux/arm64/v8 -t djeeberjr/{{cookiecutter.project_slug}} . --push | ||||
							
								
								
									
										10
									
								
								{{cookiecutter.project_slug}}/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								{{cookiecutter.project_slug}}/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| # {{cookiecutter.project_name}} | ||||
| 
 | ||||
| ## Build | ||||
| 
 | ||||
| `make build`  | ||||
| 
 | ||||
| ## Build and push docker image | ||||
| 
 | ||||
| `make docker` | ||||
| 
 | ||||
| @ -0,0 +1,19 @@ | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	{{cookiecutter.mod_name}} "{{cookiecutter.mod_base}}/internal" | ||||
| 	"github.com/alexflint/go-arg" | ||||
| ) | ||||
| 
 | ||||
| type args struct { | ||||
| 	Parameter string `arg:"--parameter,required,env:PARAMETER" placeholder:"PARAMETER"` | ||||
| } | ||||
| 
 | ||||
| func main() { | ||||
| 	var args args | ||||
| 	arg.MustParse(&args) | ||||
| 
 | ||||
| 	{{cookiecutter.mod_name}}.Start({{cookiecutter.mod_name}}.Config{ | ||||
| 		Parameter: args.Parameter, | ||||
| 	}) | ||||
| } | ||||
| @ -0,0 +1,12 @@ | ||||
| package {{cookiecutter.mod_name}} | ||||
| 
 | ||||
| import "fmt" | ||||
| 
 | ||||
| type Config struct { | ||||
| 	Parameter string | ||||
| } | ||||
| 
 | ||||
| func Start(config Config)  { | ||||
| 	fmt.Println("Starting {{cookiecutter.project_slug}}") | ||||
| 	fmt.Println("Parameter: ", config.Parameter) | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user