.
Some checks failed
Deploy to Mac Mini / Test (push) Failing after 54s
Deploy to Mac Mini / Deploy (push) Has been skipped

This commit is contained in:
2026-02-26 21:33:22 +09:00
parent dabf1f3ba9
commit 3240b57dca
5 changed files with 124 additions and 4 deletions

View File

@@ -0,0 +1,45 @@
name: Deploy to Mac Mini
on:
push:
branches:
- main
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Run tests
run: go test ./... -race
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy to Mac Mini via SSH
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
port: ${{ secrets.DEPLOY_PORT || 22 }}
script: |
cd ${{ secrets.DEPLOY_PATH }}
git pull origin main
docker-compose down
docker-compose up -d --build
docker-compose logs --tail=20 server

24
Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
# Build stage
FROM golang:1.25-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o bin/server ./cmd/server
# Run stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /app
COPY --from=builder /app/bin/server .
COPY --from=builder /app/config ./config
EXPOSE 8080
CMD ["./server", "-config", "config/config.yaml"]

BIN
bin/server.exe Normal file

Binary file not shown.

View File

@@ -50,12 +50,12 @@ type AOIConfig struct {
} }
type NetworkConfig struct { type NetworkConfig struct {
WriteBufferSize int `yaml:"write_buffer_size"` WriteBufferSize int `yaml:"write_buffer_size"`
ReadBufferSize int `yaml:"read_buffer_size"` ReadBufferSize int `yaml:"read_buffer_size"`
SendChannelSize int `yaml:"send_channel_size"` SendChannelSize int `yaml:"send_channel_size"`
HeartbeatInterval time.Duration `yaml:"heartbeat_interval"` HeartbeatInterval time.Duration `yaml:"heartbeat_interval"`
HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"` HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"`
MaxMessageSize int64 `yaml:"max_message_size"` MaxMessageSize int64 `yaml:"max_message_size"`
} }
type LogConfig struct { type LogConfig struct {
@@ -81,6 +81,23 @@ func Load(path string) (*Config, error) {
return nil, fmt.Errorf("parse config file: %w", err) return nil, fmt.Errorf("parse config file: %w", err)
} }
// 환경변수로 DB 접속 정보 오버라이드 (Docker 환경용)
if v := os.Getenv("DB_HOST"); v != "" {
cfg.Database.Host = v
}
if v := os.Getenv("DB_PORT"); v != "" {
fmt.Sscanf(v, "%d", &cfg.Database.Port)
}
if v := os.Getenv("DB_USER"); v != "" {
cfg.Database.User = v
}
if v := os.Getenv("DB_PASSWORD"); v != "" {
cfg.Database.Password = v
}
if v := os.Getenv("DB_NAME"); v != "" {
cfg.Database.DBName = v
}
return cfg, nil return cfg, nil
} }

34
docker-compose.yml Normal file
View File

@@ -0,0 +1,34 @@
services:
db:
image: postgres:16-alpine
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: mmorpg
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
server:
build: .
restart: always
ports:
- "8080:8080"
depends_on:
db:
condition: service_healthy
environment:
- DB_HOST=db
- DB_USER=postgres
- DB_PASSWORD=postgres
- DB_NAME=mmorpg
volumes:
- ./config:/app/config
volumes:
postgres_data: