mirror of
https://github.com/elyby/chrly.git
synced 2026-11-29 03:03:20 +05:30
Rework project's structure
This commit is contained in:
69 files changed
+130
-161
No files matched your search
@@ -1,2 +0,0 @@
|
||||
data
|
||||
vendor
|
||||
@@ -26,8 +26,21 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- id: version
|
||||
name: Set up build version
|
||||
run: |
|
||||
if [[ $GITHUB_REF_TYPE == "tag" ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
else
|
||||
BRANCH_NAME=${GITHUB_REF#refs/heads/}
|
||||
SHORT_SHA=$(git rev-parse --short $GITHUB_SHA)
|
||||
VERSION="${BRANCH_NAME}-${SHORT_SHA}"
|
||||
fi
|
||||
echo "### Version: $VERSION" >> $GITHUB_STEP_SUMMARY
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
cache-dependency-path: go.sum
|
||||
go-version-file: go.mod
|
||||
@@ -45,9 +58,23 @@ jobs:
|
||||
run: go test -v -race --tags redis -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v4-beta
|
||||
uses: codecov/codecov-action@v4
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
- name: Build
|
||||
run: go build ./...
|
||||
env:
|
||||
CGO_ENABLED: 'false'
|
||||
run: >
|
||||
go build
|
||||
-trimpath
|
||||
-ldflags "-w -s -X github.com/elyby/chrly/internal/version.version=${{ steps.version.outputs.version }} -X github.com/elyby/chrly/internal/version.commit=${{ github.sha }}" \
|
||||
-o ./chrly
|
||||
./cmd/chrly/...
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: chrly-build-linux-amd64-${{ steps.version.outputs.version }}
|
||||
path: ./chrly
|
||||
compression-level: 0
|
||||
+11
-5
@@ -1,5 +1,11 @@
|
||||
.idea
|
||||
docker-compose.yml
|
||||
docker-compose.override.yml
|
||||
vendor
|
||||
.cover
|
||||
# IDE files
|
||||
.idea/
|
||||
*.iml
|
||||
.vscode
|
||||
|
||||
# Go mod vendoring
|
||||
/vendor
|
||||
|
||||
# Local environment
|
||||
/docker-compose.yml
|
||||
/data
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM golang:1.21-alpine AS builder
|
||||
|
||||
ARG VERSION=unversioned
|
||||
ARG COMMIT=unspecified
|
||||
|
||||
COPY . /build
|
||||
WORKDIR /build
|
||||
RUN go mod download
|
||||
|
||||
RUN CGO_ENABLED=0 \
|
||||
go build \
|
||||
-trimpath \
|
||||
-ldflags "-w -s -X github.com/elyby/chrly/version.version=$VERSION -X github.com/elyby/chrly/version.commit=$COMMIT" \
|
||||
-o chrly \
|
||||
main.go
|
||||
|
||||
FROM alpine:3.19
|
||||
|
||||
EXPOSE 80
|
||||
ENV STORAGE_REDIS_HOST=redis
|
||||
ENV STORAGE_FILESYSTEM_HOST=/data
|
||||
|
||||
COPY docker-entrypoint.sh /
|
||||
COPY --from=builder /build/chrly /usr/local/bin/chrly
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["serve"]
|
||||
@@ -0,0 +1,12 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
ARG BINARY
|
||||
|
||||
FROM scratch
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
COPY ${BINARY} /usr/local/bin/chrly
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/chrly"]
|
||||
CMD ["serve"]
|
||||
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
. "github.com/elyby/chrly/internal/cmd"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := RootCmd.Execute()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,16 @@
|
||||
version: '3'
|
||||
services:
|
||||
chrly:
|
||||
image: elyby/chrly:latest
|
||||
restart: always
|
||||
ports:
|
||||
- "80:80"
|
||||
environment:
|
||||
CHRLY_SECRET: replace_this_value_in_production
|
||||
STORAGE_REDIS_HOST: redis
|
||||
|
||||
redis:
|
||||
image: redis:latest
|
||||
restart: always
|
||||
volumes:
|
||||
- ./data/redis:/data
|
||||
@@ -1,14 +0,0 @@
|
||||
# This file can be used to start up necessary services.
|
||||
# Copy it into the docker-compose.yml:
|
||||
# > cp docker-compose.dev.yml docker-compose.yml
|
||||
# And then run it:
|
||||
# > docker-compose up -d
|
||||
|
||||
version: '2'
|
||||
services:
|
||||
redis:
|
||||
image: redis:4.0-32bit
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- ./data/redis:/data
|
||||
@@ -1,27 +0,0 @@
|
||||
# This file can be used to run application in the production environment.
|
||||
# Copy it into the docker-compose.yml:
|
||||
# > cp docker-compose.prod.yml docker-compose.yml
|
||||
# And then run it:
|
||||
# > docker-compose up -d
|
||||
# Service will be listened at the http://localhost
|
||||
|
||||
version: '2'
|
||||
services:
|
||||
app:
|
||||
image: elyby/chrly
|
||||
hostname: chrly0
|
||||
restart: always
|
||||
links:
|
||||
- redis
|
||||
volumes:
|
||||
- ./data/capes:/data/capes
|
||||
ports:
|
||||
- "80:80"
|
||||
environment:
|
||||
CHRLY_SECRET: replace_this_value_in_production
|
||||
|
||||
redis:
|
||||
image: redis:4.0-32bit # 32-bit version is recommended to spare some memory
|
||||
restart: always
|
||||
volumes:
|
||||
- ./data/redis:/data
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ ! -d /data/capes ]; then
|
||||
mkdir -p /data/capes
|
||||
fi
|
||||
|
||||
if [ "$1" = "serve" ] || [ "$1" = "token" ] || [ "$1" = "version" ]; then
|
||||
set -- /usr/local/bin/chrly "$@"
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
@@ -1,35 +1,24 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
. "github.com/defval/di"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/elyby/chrly/di"
|
||||
"github.com/elyby/chrly/http"
|
||||
"github.com/elyby/chrly/version"
|
||||
"github.com/elyby/chrly/internal/di"
|
||||
"github.com/elyby/chrly/internal/http"
|
||||
"github.com/elyby/chrly/internal/version"
|
||||
)
|
||||
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "chrly",
|
||||
Short: "Implementation of Minecraft skins system server",
|
||||
Short: "Implementation of the Minecraft skins system server",
|
||||
Version: version.Version(),
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
if err := RootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func shouldGetContainer() *Container {
|
||||
container, err := di.New()
|
||||
if err != nil {
|
||||
File renamed without changes.
File renamed without changes.
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/elyby/chrly/http"
|
||||
"github.com/elyby/chrly/internal/http"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/elyby/chrly/version"
|
||||
"github.com/elyby/chrly/internal/version"
|
||||
)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
File renamed without changes.
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/mediocregopher/radix/v4"
|
||||
|
||||
"github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/internal/db"
|
||||
)
|
||||
|
||||
const usernameToProfileKey = "hash:username-to-profile"
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
assert "github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/internal/db"
|
||||
)
|
||||
|
||||
var redisAddr string
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -7,11 +7,11 @@ import (
|
||||
"github.com/defval/di"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
db2 "github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/db/redis"
|
||||
es "github.com/elyby/chrly/eventsubscribers"
|
||||
db2 "github.com/elyby/chrly/internal/db"
|
||||
"github.com/elyby/chrly/internal/db/redis"
|
||||
es "github.com/elyby/chrly/internal/eventsubscribers"
|
||||
"github.com/elyby/chrly/internal/mojang"
|
||||
"github.com/elyby/chrly/internal/profiles"
|
||||
"github.com/elyby/chrly/mojang"
|
||||
)
|
||||
|
||||
// v4 had the idea that it would be possible to separate backends for storing skins and capes.
|
||||
File renamed without changes.
@@ -4,9 +4,9 @@ import (
|
||||
"github.com/defval/di"
|
||||
"github.com/mono83/slf"
|
||||
|
||||
d "github.com/elyby/chrly/dispatcher"
|
||||
"github.com/elyby/chrly/eventsubscribers"
|
||||
"github.com/elyby/chrly/http"
|
||||
d "github.com/elyby/chrly/internal/dispatcher"
|
||||
"github.com/elyby/chrly/internal/eventsubscribers"
|
||||
"github.com/elyby/chrly/internal/http"
|
||||
)
|
||||
|
||||
var dispatcher = di.Options(
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
. "github.com/elyby/chrly/http"
|
||||
. "github.com/elyby/chrly/internal/http"
|
||||
)
|
||||
|
||||
var handlers = di.Options(
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/mono83/slf/wd"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/elyby/chrly/eventsubscribers"
|
||||
"github.com/elyby/chrly/version"
|
||||
"github.com/elyby/chrly/internal/eventsubscribers"
|
||||
"github.com/elyby/chrly/internal/version"
|
||||
)
|
||||
|
||||
var logger = di.Options(
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"github.com/defval/di"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/elyby/chrly/internal/mojang"
|
||||
"github.com/elyby/chrly/internal/profiles"
|
||||
"github.com/elyby/chrly/mojang"
|
||||
)
|
||||
|
||||
var mojangTextures = di.Options(
|
||||
@@ -3,7 +3,7 @@ package di
|
||||
import (
|
||||
"github.com/defval/di"
|
||||
|
||||
. "github.com/elyby/chrly/http"
|
||||
. "github.com/elyby/chrly/internal/http"
|
||||
"github.com/elyby/chrly/internal/profiles"
|
||||
)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/getsentry/raven-go"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
. "github.com/elyby/chrly/http"
|
||||
. "github.com/elyby/chrly/internal/http"
|
||||
)
|
||||
|
||||
var server = di.Options(
|
||||
@@ -5,10 +5,11 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"github.com/elyby/chrly/http"
|
||||
. "github.com/elyby/chrly/signer"
|
||||
"strings"
|
||||
|
||||
"github.com/elyby/chrly/internal/http"
|
||||
. "github.com/elyby/chrly/internal/signer"
|
||||
|
||||
"github.com/defval/di"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/mono83/slf/params"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
||||
"github.com/elyby/chrly/dispatcher"
|
||||
"github.com/elyby/chrly/internal/dispatcher"
|
||||
)
|
||||
|
||||
type LoggerMock struct {
|
||||
File renamed without changes.
+1
-1
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/mono83/slf"
|
||||
|
||||
"github.com/elyby/chrly/dispatcher"
|
||||
"github.com/elyby/chrly/internal/dispatcher"
|
||||
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
package eventsubscribers
|
||||
|
||||
import "github.com/elyby/chrly/dispatcher"
|
||||
import "github.com/elyby/chrly/internal/dispatcher"
|
||||
|
||||
type Subscriber interface {
|
||||
dispatcher.Subscriber
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/internal/db"
|
||||
"github.com/elyby/chrly/internal/profiles"
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/internal/db"
|
||||
"github.com/elyby/chrly/internal/profiles"
|
||||
)
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
"github.com/mono83/slf"
|
||||
"github.com/mono83/slf/wd"
|
||||
|
||||
"github.com/elyby/chrly/dispatcher"
|
||||
v "github.com/elyby/chrly/version"
|
||||
"github.com/elyby/chrly/internal/dispatcher"
|
||||
v "github.com/elyby/chrly/internal/version"
|
||||
)
|
||||
|
||||
type Emitter interface {
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -12,9 +12,9 @@ import (
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/mojang"
|
||||
"github.com/elyby/chrly/utils"
|
||||
"github.com/elyby/chrly/internal/db"
|
||||
"github.com/elyby/chrly/internal/mojang"
|
||||
"github.com/elyby/chrly/internal/utils"
|
||||
)
|
||||
|
||||
var timeNow = time.Now
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
testify "github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/internal/db"
|
||||
)
|
||||
|
||||
type ProfilesProviderMock struct {
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/elyby/chrly/utils"
|
||||
"github.com/elyby/chrly/internal/utils"
|
||||
)
|
||||
|
||||
type BatchUuidsProvider struct {
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
|
||||
"github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/internal/db"
|
||||
)
|
||||
|
||||
type ProfilesRepository interface {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/internal/db"
|
||||
)
|
||||
|
||||
type ProfilesRepositoryMock struct {
|
||||
|
||||
@@ -3,8 +3,8 @@ package profiles
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/mojang"
|
||||
"github.com/elyby/chrly/internal/db"
|
||||
"github.com/elyby/chrly/internal/mojang"
|
||||
)
|
||||
|
||||
type ProfilesFinder interface {
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/elyby/chrly/db"
|
||||
"github.com/elyby/chrly/mojang"
|
||||
"github.com/elyby/chrly/utils"
|
||||
"github.com/elyby/chrly/internal/db"
|
||||
"github.com/elyby/chrly/internal/mojang"
|
||||
"github.com/elyby/chrly/internal/utils"
|
||||
)
|
||||
|
||||
type ProfilesFinderMock struct {
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,8 +1,8 @@
|
||||
package version
|
||||
|
||||
var (
|
||||
version = ""
|
||||
commit = ""
|
||||
version = "undefined"
|
||||
commit = "unknown"
|
||||
)
|
||||
|
||||
func Version() string {
|
||||
Reference in new issue
Block a user