Skip to content

Commit

Permalink
init greeter server
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Sep 8, 2023
1 parent f1cd875 commit c3e4c18
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
57 changes: 57 additions & 0 deletions .github/workflows/builder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: builder

on:
push:
tags:
- "v*.*.*"

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
bavix/greeter-server
ghcr.io/bavix/greeter-server
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Login to Dockerhub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_LOGIN }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

# Go workspace file
go.work

.idea/
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARG BUILD_ARG_GO_VERSION=1.21
ARG BUILD_ARG_ALPINE_VERSION=3.18
FROM golang:${BUILD_ARG_GO_VERSION}-alpine${BUILD_ARG_ALPINE_VERSION} AS builder
RUN apk add --update --no-cache curl ca-certificates

WORKDIR /src

COPY . .

RUN curl "https://raw.githubusercontent.com/grpc/grpc-go/master/examples/helloworld/greeter_server/main.go" -o main.go

RUN go mod tidy && go build -o greeter

FROM alpine:${BUILD_ARG_ALPINE_VERSION}
WORKDIR /
ENV USER=greeter
ENV UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
RUN apk add --update --no-cache tzdata curl

COPY --from=builder /src/greeter .

USER greeter:greeter

CMD ["/greeter"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Greeter Server builder

Automatically builds a greeter server build from source: https://github.com/grpc/grpc-go

---
Supported by

[![Supported by JetBrains](https://cdn.rawgit.com/bavix/development-through/46475b4b/jetbrains.svg)](https://www.jetbrains.com/)
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/bavix/greeter-server

go 1.21.0

0 comments on commit c3e4c18

Please sign in to comment.