Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
oddmario committed Sep 9, 2024
2 parents 2e4cb48 + af3f20c commit dbede41
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
39 changes: 39 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Push Docker Image

on:
workflow_dispatch:
release:
types:
- published

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3

- name: Extract metadata for Docker
id: metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/oddmario/simple-dns-server

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

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Stage 1: Build the Go application
FROM golang:1.22.6-alpine AS builder

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o simpledns .

# Stage 2: Create a minimal image with the built application
FROM gcr.io/distroless/static:latest

COPY --from=builder /app/simpledns /simpledns
ENTRYPOINT ["/simpledns"]

EXPOSE 53
2 changes: 1 addition & 1 deletion config.example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"mode": "db",
"mode": "static_records",
"db": {
"host": "localhost",
"username": "root",
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
simpledns:
image: ghcr.io/oddmario/simple-dns-server
restart: always
ports:
- 53:53/udp
volumes:
- ./config.json:/config.json:ro

0 comments on commit dbede41

Please sign in to comment.