mirror of
				https://github.com/dancojocaru2000/CfrTrainInfoTelegramBot.git
				synced 2025-11-04 08:56:39 +02:00 
			
		
		
		
	Allow CGO in Docker build
go-sqlite3 requires cgo to work
This commit is contained in:
		
							parent
							
								
									69a0cf3a01
								
							
						
					
					
						commit
						037e7d03dc
					
				
					 1 changed files with 11 additions and 2 deletions
				
			
		
							
								
								
									
										13
									
								
								Dockerfile
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								Dockerfile
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,8 +1,16 @@
 | 
			
		|||
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
 | 
			
		||||
 | 
			
		||||
FROM --platform=$BUILDPLATFORM golang:1.21-alpine AS build
 | 
			
		||||
 | 
			
		||||
LABEL authors="kbruen"
 | 
			
		||||
LABEL org.opencontainers.image.source=https://github.com/dancojocaru2000/CfrTrainInfoTelegramBot
 | 
			
		||||
 | 
			
		||||
RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
 | 
			
		||||
RUN apk add zig@testing
 | 
			
		||||
COPY --from=xx / /
 | 
			
		||||
ARG TARGETPLATFORM
 | 
			
		||||
ENV CGO_ENABLED=1
 | 
			
		||||
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
 | 
			
		||||
COPY go.mod .
 | 
			
		||||
| 
						 | 
				
			
			@ -11,8 +19,9 @@ RUN go mod download
 | 
			
		|||
 | 
			
		||||
COPY main.go ./
 | 
			
		||||
COPY pkg ./pkg/
 | 
			
		||||
ARG TARGETOS TARGETARCH
 | 
			
		||||
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o server
 | 
			
		||||
ARG TARGETOS
 | 
			
		||||
ARG TARGETARCH
 | 
			
		||||
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_CFLAGS="-D_LARGEFILE64_SOURCE" CC="zig cc -target $(xx-info march)-$(xx-info os)-$(xx-info libc)" CXX="zig c++ -target $(xx-info march)-$(xx-info os)-$(xx-info libc)" go build -o server && xx-verify server
 | 
			
		||||
 | 
			
		||||
FROM scratch
 | 
			
		||||
COPY --from=build /etc/ssl/certs /etc/ssl/certs
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue