diff --git a/Dockerfile b/Dockerfile index 55eaae4..646e896 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,12 @@ -# Use the official Go image as the base image -FROM golang:1.22.6 +FROM golang:1.22 -# Set the working directory inside the container -WORKDIR /app +WORKDIR /usr/src/app + +# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change +COPY go.mod go.sum ./ +RUN go mod download && go mod verify -# Copy the source code into the container COPY . . +RUN go build -v -o /usr/local/bin/app ./cmd/video_server_backend/main.go -# Build the Go application -RUN go build -o app ./cmd/video_server_backend/main.go - -# Set the entry point for the container -ENTRYPOINT ["./app"] \ No newline at end of file +CMD ["app"] diff --git a/Jenkinsfile b/Jenkinsfile index 30b3963..7db209c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,9 @@ pipeline { - agent any + agent { + docker { + image 'docker:latest' + } + } stages { stage('Docker build') {