Skip to content

Commit 30848df

Browse files
committed
Fixes docker config and adds gin router
1 parent 3dc84fd commit 30848df

File tree

14 files changed

+340
-156
lines changed

14 files changed

+340
-156
lines changed

.dockerignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Build artifacts
2+
build/
3+
vendor/
4+
5+
# Development files
6+
.env
7+
*.log
8+
9+
# IDE files
10+
.vscode/
11+
.idea/
12+
*.swp
13+
*.swo
14+
15+
# OS files
16+
.DS_Store
17+
Thumbs.db
18+
19+
# Docker files
20+
Dockerfile*
21+
docker-compose*.yaml
22+
dev.sh

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
vendor/
16-
v1.46.2/
1716

1817
# Exclude the binary
1918
nymeria
2019
!nymeria/
2120

2221
# Exclude the config file
2322
config.yaml
24-
/config/kratos.yml
2523

2624
# miscellaneous
2725
.vscode/
@@ -37,4 +35,8 @@ target/
3735

3836
config.docker.yaml
3937

40-
logs
38+
logs
39+
40+
.env
41+
42+
.DS_Store

Dockerfile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1-
FROM golang:1.23-alpine
1+
FROM golang:1.23-alpine AS base
22

33
WORKDIR /app
44

5-
COPY . /app/
5+
ENV GOPROXY=direct
66

7-
RUN export GOPROXY=direct
7+
RUN apk add --no-cache make postgresql-client git curl
88

9+
COPY go.mod go.sum ./
10+
RUN go mod download
11+
12+
# Development Mode
13+
FROM base AS dev
14+
COPY . .
15+
RUN make install-tools
916
EXPOSE 9898
17+
CMD ["make", "dev"]
1018

11-
# install make, psql
12-
RUN apk add --no-cache make postgresql-client
19+
# Production Mode
20+
FROM base AS prod
21+
COPY . .
1322
RUN make build
14-
15-
CMD ["./nymeria"]
23+
EXPOSE 9898
24+
CMD ["./build/nymeria"]

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,19 @@ test-short:
5757
install-tools: install-golangci-lint install-goimports install-air
5858

5959
install-golangci-lint:
60+
@echo "Installing golangci-lint..."
6061
@if [ ! -f $(GOLANGCI_LINT) ]; then \
61-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
62-
sh -s -- -b $(GOPATH_BIN) v2.1.6; \
62+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(GOPATH_BIN) v2.1.6; \
6363
fi
6464

6565
install-goimports:
66+
@echo "Installing goimports..."
6667
@if [ ! -f $(GOIMPORTS) ]; then \
6768
$(GO) install golang.org/x/tools/cmd/goimports@latest; \
6869
fi
6970

7071
install-air:
72+
@echo "Installing air..."
7173
@if [ ! -f $(AIR) ]; then \
7274
curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(GOPATH_BIN); \
7375
fi

dev.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Development environment runner script
4+
echo "🚀 Starting development environment..."
5+
6+
# Build and run with docker-compose dev configuration
7+
docker-compose -f docker-compose.dev.yaml up --build --force-recreate
8+
9+
# Cleanup function
10+
cleanup() {
11+
echo "🧹 Cleaning up..."
12+
docker-compose -f docker-compose.dev.yaml down
13+
}
14+
15+
# Set trap to cleanup on script exit
16+
trap cleanup EXIT

docker-compose.dev.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
services:
2+
app:
3+
build:
4+
context: .
5+
target: dev
6+
ports:
7+
- "9898:9898"
8+
depends_on:
9+
- db
10+
environment:
11+
- DB_HOST=db
12+
- DB_USER=${DB_USER:-nymeria}
13+
- DB_PASS=${DB_PASS:-password}
14+
- DB_NAME=${DB_NAME:-nymeria}
15+
- DB_PORT=5432
16+
volumes:
17+
- .:/app
18+
command: ["make", "dev"]
19+
restart: unless-stopped
20+
21+
db:
22+
image: postgres:15-alpine
23+
volumes:
24+
- postgres_data_dev:/var/lib/postgresql/data
25+
environment:
26+
- POSTGRES_USER=${DB_USER:-nymeria}
27+
- POSTGRES_PASSWORD=${DB_PASS:-password}
28+
- POSTGRES_DB=${DB_NAME:-nymeria}
29+
ports:
30+
- "5432:5432"
31+
restart: unless-stopped
32+
33+
volumes:
34+
postgres_data_dev:

docker-compose.prod.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
services:
2+
app:
3+
build:
4+
context: .
5+
target: prod
6+
ports:
7+
- "9898:9898"
8+
depends_on:
9+
- db
10+
environment:
11+
- DB_HOST=db
12+
- DB_USER=${DB_USER:-nymeria}
13+
- DB_PASS=${DB_PASS:-password}
14+
- DB_NAME=${DB_NAME:-nymeria}
15+
- DB_PORT=5432
16+
restart: unless-stopped
17+
18+
db:
19+
image: postgres:15-alpine
20+
volumes:
21+
- postgres_data:/var/lib/postgresql/data
22+
environment:
23+
- POSTGRES_USER=${DB_USER:-nymeria}
24+
- POSTGRES_PASSWORD=${DB_PASS:-password}
25+
- POSTGRES_DB=${DB_NAME:-nymeria}
26+
ports:
27+
- "5432:5432"
28+
restart: unless-stopped
29+
30+
volumes:
31+
postgres_data:

docker-compose.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

go.mod

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,55 @@ module github.com/sdslabs/nymeria
22

33
go 1.23.0
44

5-
toolchain go1.24.0
6-
75
require (
8-
github.com/go-chi/chi/v5 v5.2.1
9-
github.com/go-chi/cors v1.2.1
6+
github.com/gin-contrib/cors v1.7.5
7+
github.com/gin-gonic/gin v1.10.1
108
github.com/rs/zerolog v1.34.0
119
github.com/stretchr/testify v1.10.0
1210
gorm.io/gorm v1.30.0
1311
)
1412

1513
require (
14+
github.com/bytedance/sonic v1.13.2 // indirect
15+
github.com/bytedance/sonic/loader v0.2.4 // indirect
16+
github.com/cloudwego/base64x v0.1.5 // indirect
1617
github.com/davecgh/go-spew v1.1.1 // indirect
18+
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
19+
github.com/gin-contrib/sse v1.0.0 // indirect
20+
github.com/go-playground/locales v0.14.1 // indirect
21+
github.com/go-playground/universal-translator v0.18.1 // indirect
22+
github.com/go-playground/validator/v10 v10.26.0 // indirect
23+
github.com/goccy/go-json v0.10.5 // indirect
1724
github.com/jackc/pgpassfile v1.0.0 // indirect
1825
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
1926
github.com/jackc/pgx/v5 v5.6.0 // indirect
2027
github.com/jackc/puddle/v2 v2.2.2 // indirect
2128
github.com/jinzhu/inflection v1.0.0 // indirect
2229
github.com/jinzhu/now v1.1.5 // indirect
30+
github.com/json-iterator/go v1.1.12 // indirect
31+
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
32+
github.com/leodido/go-urn v1.4.0 // indirect
2333
github.com/mattn/go-colorable v0.1.14 // indirect
34+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
35+
github.com/modern-go/reflect2 v1.0.2 // indirect
36+
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
2437
github.com/pmezard/go-difflib v1.0.0 // indirect
2538
github.com/rogpeppe/go-internal v1.12.0 // indirect
39+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
40+
github.com/ugorji/go/codec v1.2.12 // indirect
41+
golang.org/x/arch v0.15.0 // indirect
42+
golang.org/x/net v0.38.0 // indirect
2643
golang.org/x/sync v0.15.0 // indirect
44+
google.golang.org/protobuf v1.36.6 // indirect
2745
)
2846

2947
require (
3048
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
31-
github.com/go-chi/chi v1.5.5
3249
github.com/kr/text v0.2.0 // indirect
3350
github.com/mattn/go-isatty v0.0.20 // indirect
3451
github.com/pkg/errors v0.9.1
3552
github.com/pquerna/otp v1.5.0
36-
golang.org/x/crypto v0.31.0 // indirect
53+
golang.org/x/crypto v0.36.0 // indirect
3754
golang.org/x/sys v0.33.0 // indirect
3855
golang.org/x/text v0.26.0 // indirect
3956
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)