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

[JOH-37] Docker #8

Merged
merged 18 commits into from
Jan 6, 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
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build

on:
workflow_dispatch:
push:
branches:
- main
- beta
- dev
- master

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
IMAGE_TAG: ${{ github.sha }}

jobs:
build:
name: Build
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

outputs:
BRANCH: ${{ steps.branch.outputs.BRANCH }}

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

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

- name: Set branch
id: branch
run: |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT

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

- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Johnjud-gateway

Johnjud-gateway is a routing and request handling service for the Johnjud project.

### What is Johnjud?
Johnjud is a pet adoption web application of the [CUVET For Animal Welfare Club](https://www.facebook.com/CUVETforAnimalWelfareClub)

## Stack

- golang
Expand All @@ -17,7 +22,7 @@
### Installation

1. Clone this repo
2. Copy `config.example.yaml` in `config` and paste it in the same directory with `.example` removed from its name.
2. Copy every `config.example.yaml` in `config` and paste it in the same directory with `.example` removed from its name.

3. Run `go mod download` to download all the dependencies.

Expand All @@ -27,3 +32,12 @@

### Testing
1. Run `make test` or `go test -v -coverpkg ./... -coverprofile coverage.out -covermode count ./...`

## Other microservices/repositories of Johnjud
- [Johnjud-gateway](https://github.com/isd-sgcu/johnjud-gateway): Routing and request handling
- [Johnjud-auth](https://github.com/isd-sgcu/johnjud-auth): Authentication and authorization
- [Johnjud-backend](https://github.com/isd-sgcu/johnjud-backend): Main business logic
- [Johnjud-file](https://github.com/isd-sgcu/johnjud-file): File management service
- [Johnjud-proto](https://github.com/isd-sgcu/johnjud-proto): Protobuf files generator
- [Johnjud-go-proto](https://github.com/isd-sgcu/johnjud-go-proto): Generated protobuf files for golang
- [Johnjud-frontend](https://github.com/isd-sgcu/johnjud-frontend): Frontend web application
23 changes: 23 additions & 0 deletions config/auth/config.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
app:
port: 3002
debug: true
secret: <secret>

database:
host: localhost
port: 5432
name: johnjud_db
username: root
password: root

jwt:
secret: <secret>
expires_in: 3600
refresh_token_ttl: 604800
issuer: <issuer>

redis:
host: localhost
port: 6379
password: ""
dbnum: 0
13 changes: 13 additions & 0 deletions config/backend/config.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
app:
port: 3003
debug: true

database:
host: local-db
port: 5432
name: johnjud_db
username: root
password: root

service:
file: file:3004
14 changes: 14 additions & 0 deletions config/file/config.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
app:
port: 3004
debug: true

database:
host: local-db
port: 5432
name: johnjud_db
username: root
password: root

s3:
bucket_name: <bucket name>
region: <region>
80 changes: 80 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
version: "3.9"

services:
local-auth:
image: ghcr.io/isd-sgcu/johnjud-auth
container_name: auth
depends_on:
- local-db
- local-cache
restart: unless-stopped
networks:
- johnjud-local
- database
volumes:
- ./config/auth:/app/config
ports:
- "3002:3002"

local-backend:
image: ghcr.io/isd-sgcu/johnjud-backend
container_name: backend
depends_on:
- local-db
- local-cache
restart: unless-stopped
networks:
- johnjud-local
- database
volumes:
- ./config/backend:/app/config
ports:
- "3003:3003"

local-file:
image: ghcr.io/isd-sgcu/johnjud-file
container_name: file
depends_on:
- local-db
- local-cache
restart: unless-stopped
networks:
- johnjud-local
- database
volumes:
- ./config/file:/app/config
ports:
- "3004:3004"

local-db:
image: postgres:15.1-alpine3.17
container_name: local-db
restart: unless-stopped
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: johnjud_db
networks:
- database
volumes:
- ./volumes/postgres:/var/lib/postgresql/data
ports:
- "5432:5432"

local-cache:
image: redis:7.2.3-alpine
container_name: local-cache
restart: unless-stopped
environment:
REDIS_HOST: localhost
ALLOW_EMPTY_PASSWORD: "yes"
networks:
- database
ports:
- "6379:6379"

networks:
johnjud-local:
name: johnjud-local
database:
name: database
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/go-playground/locales v0.14.1
github.com/go-playground/universal-translator v0.18.1
github.com/go-playground/validator/v10 v10.16.0
github.com/gofiber/fiber/v2 v2.51.0
github.com/gofiber/fiber/v2 v2.52.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.5.0
github.com/isd-sgcu/johnjud-go-proto v0.2.2
Expand All @@ -23,18 +23,18 @@ require (

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/andybalholm/brotli v1.0.6 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/spec v0.20.13 // indirect
github.com/go-openapi/swag v0.22.6 // indirect
github.com/go-openapi/swag v0.22.7 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand All @@ -44,7 +44,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
Expand All @@ -53,16 +53,16 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2 // indirect
github.com/swaggo/files v1.0.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.50.0 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.16.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
Expand Down
Loading
Loading