Skip to content

Commit

Permalink
Merge pull request #24 from Hossara/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Hossara authored Jan 25, 2025
2 parents cc6402a + 76292e9 commit 93a9ff9
Show file tree
Hide file tree
Showing 90 changed files with 4,739 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea
config.json
vendor

# Added by goreleaser init:
dist/

*.env
61 changes: 61 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...

builds:
- main: ./cmd/cli
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
nfpms:
- id: deb
formats:
- deb
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
maintainer: "Hossein Araghi <hoseinaraghi84@gmail.com>"
description: "A simple chatroom client/server based on Nats and implemented using Golang."
license: MIT
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

release:
footer: >-
---
Released by [GoReleaser](https://github.com/goreleaser/goreleaser).
68 changes: 68 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Variables
ROOT_DIR := ./build

NETWORK_NAME=linkin-chat-network

DEV_COMPOSE:= \
-f $(ROOT_DIR)/nats/docker-compose.yaml \
-f $(ROOT_DIR)/redis/docker-compose.dev.yaml \
-f $(ROOT_DIR)/postgres/docker-compose.dev.yaml \

PROD_COMPOSE:= \
-f $(ROOT_DIR)/nats/docker-compose.yaml \
-f $(ROOT_DIR)/redis/docker-compose.prod.yaml \
-f $(ROOT_DIR)/postgres/docker-compose.prod.yaml \
-f $(ROOT_DIR)/server/docker-compose.yaml

# Functions
ensure-network:
@echo "Ensuring project network is exists..."
@if [ -z "$$(docker network ls --filter name=$(NETWORK_NAME) --format '{{.Name}}')" ]; then \
echo "Network $(NETWORK_NAME) does not exist. Creating..."; \
docker network create $(NETWORK_NAME); \
fi

# CLI
create_release:
goreleaser release --snapshot --clean

.PHONY: create_release

# Server Development
dev_up: ensure-network
@docker compose --project-directory $(ROOT_DIR) $(DEV_COMPOSE) up -d

dev_uplog: ensure-network
@docker compose --project-directory $(ROOT_DIR) $(DEV_COMPOSE) up

dev_down: ensure-network
docker compose --project-directory $(ROOT_DIR) $(DEV_COMPOSE) down

dev_build: ensure-network
@docker compose --project-directory $(ROOT_DIR) $(DEV_COMPOSE) build $(FLAGS) $(CONTAINER)

dev_logs: ensure-network
@docker compose --project-directory $(ROOT_DIR) $(DEV_COMPOSE) logs -f

dev_rebuild: ensure-network
@docker compose --project-directory $(ROOT_DIR) $(DEV_COMPOSE) up --build

.PHONY: dev_up dev_uplog dev_down dev_build dev_logs dev_rebuild

# Server Deployment
deploy: ensure-network
docker compose --project-directory $(ROOT_DIR) $(PROD_COMPOSE) up -d

deploy-down: ensure-network
docker compose --project-directory $(ROOT_DIR) $(PROD_COMPOSE) down

deploy-logs: ensure-network
docker compose --project-directory $(ROOT_DIR) $(PROD_COMPOSE) logs -f

deploy-log: ensure-network
docker compose --project-directory $(ROOT_DIR) $(PROD_COMPOSE) logs -f $(CONTAINER)

deploy-build: ensure-network
docker compose --project-directory $(ROOT_DIR) $(PROD_COMPOSE) build $(FLAGS) $(CONTAINER)

.PHONY: deploy deploy-down deploy-logs deploy-logs deploy-build
Loading

0 comments on commit 93a9ff9

Please sign in to comment.