Use a single container for build & run

master
Araozu 2024-05-08 09:34:07 -05:00
parent e68245273d
commit 0dbe8344dd
3 changed files with 12 additions and 15 deletions

View File

@ -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 EXPOSE 8080:8080
# Copy the backend binary # Copy the backend binary
COPY ./card-jong-be . COPY ./card-jong-be .
ENTRYPOINT ["card-jong-be"] CMD ["card-jong-be"]

13
Jenkinsfile vendored
View File

@ -2,18 +2,7 @@ pipeline {
agent any agent any
stages { stages {
stage('Build binary') { stage("Run & build") {
agent {
docker {
image "golang:1.22-bookworm"
reuseNode true
}
}
steps {
sh 'go build'
}
}
stage("Deploy") {
steps { steps {
sh "docker compose up --build -d" sh "docker compose up --build -d"
} }

View File

@ -5,4 +5,3 @@ services:
build: . build: .
ports: ports:
- "9126:8080" - "9126:8080"