Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bartventer committed Dec 25, 2023
0 parents commit c2fd17e
Show file tree
Hide file tree
Showing 32 changed files with 3,656 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .devcontainer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# POSTGRES
DB_NAME=test_tenants
DB_USER=postgres
DB_PASSWORD=postgres
DB_PORT=5432
DB_HOST=tenants_db

# PGADMIN
PGADMIN_DEFAULT_EMAIL=admin@email.com
PGADMIN_DEFAULT_PASSWORD=admin
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "Gorm Multi-Tenancy",
"dockerComposeFile": [
"docker-compose.yml"
],
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"customizations": {
"vscode": {
"extensions": [
"GitHub.copilot",
"GitHub.copilot-chat",
"golang.go",
"cweijan.vscode-postgresql-client2",
"github.vscode-github-actions"
]
}
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"configureZshAsDefaultShell": true,
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"upgradePackages": true
},
"ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {
"plugins": "zsh-autosuggestions zsh-syntax-highlighting zsh-history-substring-search",
"omzPlugins": "https://github.com/zsh-users/zsh-autosuggestions.git https://github.com/zsh-users/zsh-syntax-highlighting.git https://github.com/zsh-users/zsh-history-substring-search.git"
},
"ghcr.io/devcontainers/features/aws-cli:1": {}
}
}
64 changes: 64 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
version: '3.9'

services:
app:
image: mcr.microsoft.com/devcontainers/go:1.21-bullseye
ports:
- 8080:8080
volumes:
- ../..:/workspaces:cached
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
cap_add:
- SYS_PTRACE
security_opt:
- seccomp:unconfined
depends_on:
- db
networks:
- backend
command: sleep infinity
environment:
- DB_HOST=${DB_HOST}
- DB_PORT=${DB_PORT}
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASSWORD=${DB_PASSWORD}

db:
image: postgres:15.4-alpine
restart: always
hostname: ${DB_HOST}
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
ports:
- 5432:${DB_PORT}
volumes:
- db-data:/var/lib/postgresql/data
networks:
- backend

pgadmin:
image: dpage/pgadmin4:latest
restart: always
environment:
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD}
ports:
- 5050:80
volumes:
- pgadmin-data:/var/lib/pgadmin
networks:
- backend
depends_on:
- db


volumes:
db-data:
pgadmin-data:

networks:
backend:
driver: bridge
55 changes: 55 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Go

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:
name: Build
runs-on: ubuntu-latest
env:
DB_NAME: test_tenants
DB_USER: postgres
DB_PASSWORD: postgres
DB_PORT: 5432
DB_HOST: localhost
services:
db:
image: postgres:latest
env:
POSTGRES_DB: ${{ env.DB_NAME }}
POSTGRES_USER: ${{ env.DB_USER }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 5432:5432
volumes:
- db-data:/var/lib/postgresql/data
steps:

- name: Set up Go 1.21
uses: actions/setup-go@v1
with:
go-version: 1.21
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Test
run: go test -v -coverprofile=./profile.cov ./...

- uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: ./profile.cov
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Temp folder
/tmp
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: go

sudo: false

go:
- tip

before_install:
- go get github.com/mattn/goveralls

script:
- $HOME/gopath/bin/goveralls -service=travis-ci

services:
- db
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch echo server",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/internal/examples/echo/main.go",
"env": {},
"args": []
},
{
"name": "Launch net/http server",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/internal/examples/nethttp/main.go",
"env": {},
"args": []
},
]
}
Loading

0 comments on commit c2fd17e

Please sign in to comment.