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 17 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 "::set-output name=BRANCH::${GITHUB_REF#refs/heads/}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think set-output is deprecated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!


- 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
Loading
Loading