🐳 updated Dockerfile for folder structure
Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
		
							parent
							
								
									98f25c1b32
								
							
						
					
					
						commit
						6f1db8b64a
					
				
					 1 changed files with 6 additions and 13 deletions
				
			
		|  | @ -1,25 +1,18 @@ | |||
| # syntax=docker/dockerfile:1 | ||||
| 
 | ||||
| # Start from the latest golang base image | ||||
| FROM golang:latest AS build | ||||
| FROM golang:latest | ||||
| 
 | ||||
| # Set the Current Working Directory inside the container | ||||
| WORKDIR /app | ||||
| 
 | ||||
| # Copy everything from the current directory to the PWD inside the container | ||||
| COPY . . | ||||
| COPY go.* . | ||||
| 
 | ||||
| # Download all the dependencies | ||||
| RUN go mod download | ||||
| RUN go mod download && go mod verify | ||||
| 
 | ||||
| # Build the Go app - change directory to 'cmd' where main.go resides | ||||
| RUN go build -o /app/hello ./cmd | ||||
| COPY ./cmd ./cmd | ||||
| 
 | ||||
| FROM alpine:latest | ||||
| 
 | ||||
| WORKDIR /app | ||||
| 
 | ||||
| COPY --from=build /app/hello . | ||||
| RUN go build -v -o main ./cmd | ||||
| 
 | ||||
| # Command to run the executable | ||||
| CMD ["./hello"] | ||||
| CMD ["./main"] | ||||
|  |  | |||
		Reference in a new issue