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 basic docker image #23

Merged
merged 2 commits into from
Jul 28, 2023
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
42 changes: 42 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Create and publish a Docker image

on:
push:
tags:
- v*

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang as build-env

WORKDIR /go/src/app
COPY . /go/src/app

RUN go get -d -v ./...

RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /go/bin/app /go/src/app/

FROM gcr.io/distroless/base

COPY --from=build-env /go/bin/app /app

CMD ["/app"]
34 changes: 34 additions & 0 deletions docker-compose.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3'

services:
app:
build: .
container_name: app
restart: unless-stopped
ports:
- 3000:3000
volumes:
- ./config.example.yaml:/config.yaml


nginx:
image: nginx
container_name: nginx
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- ./certs:/etc/letsencrypt
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- app

certbot:
image: certbot/certbot
container_name: certbot
restart: unless-stopped
volumes:
- ./certs:/etc/letsencrypt
- ./certbot/conf:/etc/letsencrypt
command: certonly --webroot --webroot-path=/var/www/certbot --email=<your-email> --agree-tos --no-eff-email --staging -d <your-domain-name>
Loading