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

Release 3.0 #8

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Compiled output
bin

# Documentation
docs

# Version control
.git
.gitignore

# CI/CD files.
.github

# Configuration files.
configs.yaml

# IDE Metadata
.idea
.vscode

# Secrets
keys
# Configuration files.
configs

# Logs
logs
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ bin
.idea
.vscode

# Secrets
keys
# Configs
configs/configs.yaml

# Logs
logs
Expand Down
23 changes: 20 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,46 @@ issues:
# Issues are auto fixed.
fix: true

linters-settings:
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/shivanshkc/rosenbridge) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true

linters:
# Initially all linters are enabled.
enable-all: true
# Following linters are disabled.
disable:
- deadcode
- depguard
- exhaustivestruct
- exhaustruct
- gci
- gochecknoglobals
- godox
- goerr113
- golint
- ifshort
- interfacer
- ireturn
- maligned
- nlreturn
- nosnakecase
- paralleltest
- scopelint
- structcheck
- tagliatelle
- testpackage
- paralleltest
- varcheck
- wsl
95 changes: 0 additions & 95 deletions CHANGELOG.md

This file was deleted.

16 changes: 8 additions & 8 deletions Dockerfile → Containerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#------------------------------------------------------------------
FROM golang:1.17-alpine as builder
FROM golang:1.19-alpine as builder

# Update alpine.
RUN apk update && apk upgrade

# Install alpine dependencies.
RUN apk --no-cache --update add build-base bash

# Create and change to the 'project' directory.
WORKDIR /project
# Create and change to the 'service' directory.
WORKDIR /service

# Install project dependencies.
COPY go.mod go.sum ./
Expand All @@ -19,18 +19,18 @@ COPY . .
RUN make test

# Build application binary.
RUN make build-alpine
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v -o bin/main

#-------------------------------------------------------------------
FROM alpine:3

# Create and change to the the 'project' directory.
WORKDIR /project
# Create and change to the the 'service' directory.
WORKDIR /service

# Copy the files to the production image from the builder stage.
COPY --from=builder /project/bin /project/
COPY --from=builder /service/bin /service/

# Run the web service on container startup.
CMD ["/project/main"]
CMD ["/service/main"]

#-------------------------------------------------------------------
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

38 changes: 13 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
SHELL=/usr/bin/env bash

# Project specific properties.
application_name = rosenbridge
application_binary_name = main
application_name = rosenbridge
application_binary_name = main

# Container specific properties.
application_image_name = rosenbridge
application_container_name = rosenbridge-1

# For ProtoBuf code generation.
proto_path=src/proto/*.proto
proto_path=pkg/proto/*.proto

# Builds the project.
build:
@echo "+$@"
@go build -o bin/$(application_binary_name)

# Builds the project for alpine linux.
build-alpine:
build: tidy lint
@echo "+$@"
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v -o bin/main
@go build -o bin/$(application_binary_name) cmd/$(application_name)/main.go

# Runs the project after linting and building it anew.
run: tidy lint build
@echo "+$@"
@echo "########### Running the application binary ############"
@bin/$(application_binary_name)

# Runs the project.
run-only:
run: build
@echo "+$@"
@echo "########### Running the application binary ############"
@bin/$(application_binary_name)
Expand All @@ -44,25 +35,22 @@ tidy:
# Runs golang-ci-lint over the project.
lint:
@echo "+$@"
@golangci-lint run
@golangci-lint run ./...

# Builds the docker image for the project.
image:
@echo "+$@"
@docker build -t $(application_image_name):latest .
@docker build --network host --file Containerfile --tag $(application_image_name):latest .

# Runs the project container assuming the image is already built.
container:
@echo "+$@"
@echo "############### Removing old container ################"
@docker rm -f $(application_container_name)

@echo "################ Running new container ################"
@docker run \
--detach \
--name $(application_container_name) \
--restart unless-stopped \
--net host \
--volume $(PWD)/configs.yaml:/etc/configs.yaml \
@docker run --name $(application_container_name) --detach --net host --restart unless-stopped \
--volume configs/configs.yaml:/etc/$(application_name)/configs.yaml \
$(application_image_name):latest

# Generates code using the found protocol buffer files.
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# rosenbridge
A distributed hub for fast asynchronous communication between machines.
# Rosenbridge
24 changes: 24 additions & 0 deletions cmd/rosenbridge/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import (
"github.com/shivanshkc/rosenbridge/v3/internal/http"
"github.com/shivanshkc/rosenbridge/v3/pkg/config"
"github.com/shivanshkc/rosenbridge/v3/pkg/logger"
)

func main() {
// Initialize basic dependencies.
cfg := config.Load()
log := logger.New(cfg)

// Initialize the HTTP server.
server := http.Server{
Config: cfg,
Logger: log,
Middleware: &http.Middleware{Logger: log},
}

// This internally calls ListenAndServe.
// This is a blocking call and will panic if the server is unable to start.
server.Start()
}
25 changes: 0 additions & 25 deletions configs.yaml

This file was deleted.

10 changes: 10 additions & 0 deletions configs/configs.sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
application:
name: rosenbridge

http_server:
addr: localhost:8080

logger:
level: trace
pretty: true
Loading
Loading