diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 34dffda..b7743da 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -17,23 +17,6 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.22' # Specify the desired Go version - - - name: Download Dependencies - run: | - go mod download - - - name: Build Go Binary - run: | - go build -o pogdark-api . - - - name: Confirm file presence - run: | - pwd && ls -al /workspace/public/ && ls -al . - - name: Build Docker Image run: | docker build -t localhost:5000/pogdark-api:latest . diff --git a/Dockerfile b/Dockerfile index 84a743a..31ec89c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,31 @@ -FROM scratch -COPY pogdark-api /app/pogdark-api +FROM golang:1.22-alpine AS builder + +# Set the Current Working Directory inside the container +WORKDIR /app + +# Copy go.mod and go.sum files to the workspace +COPY go.mod go.sum ./ + +# Download dependencies +RUN go mod download + +# Copy the source code into the container +COPY . . + +# Build the Go application +RUN go build -o pogdark-api . + +# Stage 2: Create a small image to run the Go application +FROM alpine:latest + +# Set the Current Working Directory inside the container +WORKDIR /app + +# Copy the pre-built binary from the builder stage +COPY --from=builder /app/pogdark-api . + +# Expose port (change if your app uses a different port) EXPOSE 8080 -CMD ["/app/pogdark-api"] \ No newline at end of file + +# Command to run the executable +CMD ["/app/pogdark-api"]