1️⃣ STEP 1: Containerize Application
- ⭐ Image Size: ~10MB
- Created Dockerfile [Multi-stage, Scrath]
- Create docker-compose file for ease of use [cmd: docker-compose up -d]
			
			
This commit is contained in:
		
							parent
							
								
									cd59e03bae
								
							
						
					
					
						commit
						974029a3db
					
				
							
								
								
									
										22
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					FROM golang:1.23-alpine as builder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					WORKDIR /app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					COPY go.mod .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RUN go mod download
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					COPY . .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RUN go build -o APP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					FROM scratch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					COPY --from=builder /app/APP .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					COPY --from=builder /app/static ./static
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EXPOSE 8080
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CMD ["./APP"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										13
									
								
								docker-compose.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								docker-compose.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					version: '3.8'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					services:
 | 
				
			||||||
 | 
					  go-app:
 | 
				
			||||||
 | 
					    build:
 | 
				
			||||||
 | 
					      context: .
 | 
				
			||||||
 | 
					      dockerfile: Dockerfile
 | 
				
			||||||
 | 
					    ports:
 | 
				
			||||||
 | 
					      - "8080:8080"
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - ./static:/app/static
 | 
				
			||||||
 | 
					#    environment:
 | 
				
			||||||
 | 
					#      - ENV=production
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user