Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Docker step #5

Merged
merged 2 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,35 @@ jobs:

- name: Build
run: go build -ldflags="-s -w" -o microq main.go

image:
name: Build Image
needs:
- build-linux-amd64
- build-linux-arm64
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: false
tags: |
ghcr.io/c16a/microq:latest
32 changes: 32 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,35 @@ jobs:

- name: Build
run: go build -ldflags="-s -w" -o microq main.go

image:
name: Build Image
needs:
- build-linux-amd64
- build-linux-arm64
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/c16a/microq:latest
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Stage 1: Build the Go application (compiler and dependencies)
FROM golang:1.22.2 AS builder

WORKDIR /app

# Copy your Go source code
COPY go.mod ./
COPY go.sum ./
RUN go mod download

COPY . .
RUN go build -ldflags="-s -w" -o microq github.com/c16a/microq

# Stage 2: Production image (slim and optimized)
FROM scratch

WORKDIR /app

# Copy only the built binary from the builder stage
COPY --from=builder /app/microq ./

# Expose the port your application listens on (replace 8080 with your actual port)
EXPOSE 8080

# Set the command to execute your binary
CMD ["microq"]
Loading