Skip to content

Commit

Permalink
Merge pull request #14 from tonitienda/feat/backend-golang-rest-docker
Browse files Browse the repository at this point in the history
Feat/backend golang rest docker
  • Loading branch information
tonitienda authored Mar 21, 2024
2 parents e4724f3 + 5b48b94 commit 5b12fc6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/build-run-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Build and Run Tests

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t backend-golang-rest backend-golang-rest
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go
name: Unit Test

on: [push]

Expand Down
19 changes: 19 additions & 0 deletions backend-golang-rest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Stage 1: Build the Go binary
FROM golang:1.22.1-alpine3.19 AS builder

WORKDIR /app

COPY . .

RUN go build -o server cmd/main.go

# Stage 2: Create a minimal runtime image
FROM alpine:3.19

WORKDIR /app

COPY --from=builder /app/server .

EXPOSE 8080

CMD ["./server"]
2 changes: 1 addition & 1 deletion backend-golang-rest/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tonitienda/kadai/backend-golang-rest

go 1.21.3
go 1.22.1

require (
github.com/gin-gonic/gin v1.9.1
Expand Down

0 comments on commit 5b12fc6

Please sign in to comment.