diff --git a/Dockerfile b/Dockerfile index 0e3e81e..7ca9f57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,15 @@ -FROM debian:bookworm +FROM golang:1.22 +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 . . +RUN go build + EXPOSE 8080:8080 # Copy the backend binary COPY ./card-jong-be . -ENTRYPOINT ["card-jong-be"] +CMD ["card-jong-be"] diff --git a/Jenkinsfile b/Jenkinsfile index b69be8b..c5fc355 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,18 +2,7 @@ pipeline { agent any stages { - stage('Build binary') { - agent { - docker { - image "golang:1.22-bookworm" - reuseNode true - } - } - steps { - sh 'go build' - } - } - stage("Deploy") { + stage("Run & build") { steps { sh "docker compose up --build -d" } diff --git a/docker-compose.yml b/docker-compose.yml index 495277a..dbb543a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,4 +5,3 @@ services: build: . ports: - "9126:8080" -