Skip to content

Instantly share code, notes, and snippets.

@creepteks
Forked from novabyte/Dockerfile
Created September 15, 2020 05:09
Show Gist options
  • Save creepteks/50a8896b28eb37a062c3d7fab9f847cc to your computer and use it in GitHub Desktop.
Save creepteks/50a8896b28eb37a062c3d7fab9f847cc to your computer and use it in GitHub Desktop.
A small Docker-based build setup to create and build Go code with Nakama server.
version: '3'
services:
postgres:
container_name: game_backend_postgres
environment:
- POSTGRES_DB=nakama
- POSTGRES_PASSWORD=localdb
expose:
- "8080"
- "5432"
image: postgres:9.6-alpine
ports:
- "5432:5432"
- "8080:8080"
volumes:
- data:/var/lib/postgresql/data
nakama:
build: .
container_name: game_backend
depends_on:
- postgres
entrypoint:
- "/bin/sh"
- "-ecx"
- >
/nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama &&
exec /nakama/nakama --database.address postgres:localdb@postgres:5432/nakama
expose:
- "7349"
- "7350"
- "7351"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7350/"]
interval: 10s
timeout: 5s
retries: 5
links:
- "postgres:db"
ports:
- "7349:7349"
- "7350:7350"
- "7351:7351"
restart: unless-stopped
volumes:
data:
FROM heroiclabs/nakama-pluginbuilder:2.11.0 AS builder
ENV GO111MODULE on
ENV CGO_ENABLED 1
WORKDIR /backend
COPY . .
RUN go build --trimpath --mod=vendor --buildmode=plugin -o ./backend.so
FROM heroiclabs/nakama:2.11.0
COPY --from=builder /backend/backend.so /nakama/data/modules
module github.com/account/reponame
go 1.14
require github.com/heroiclabs/nakama-common v1.4.0
package main
import (
"context"
"database/sql"
"github.com/heroiclabs/nakama-common/runtime"
)
//noinspection GoUnusedExportedFunction
func InitModule(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, initializer runtime.Initializer) error {
logger.Info("Backend loaded.")
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment