Skip to content

Commit 6984d98

Browse files
committed
Initial commit
0 parents  commit 6984d98

File tree

161 files changed

+15468
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+15468
-0
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Dockerfile
2+
docker-compose.yml
3+
docker-compose-dev.yml
4+
config.json
5+
paks/

.github/workflows/build.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
name: Build
8+
runs-on: self-hosted
9+
steps:
10+
- name: Set up Go
11+
uses: actions/setup-go@v2
12+
with:
13+
go-version: 1.17
14+
15+
- name: Check out code into the Go module directory
16+
uses: actions/checkout@v2
17+
18+
- name: Download dependencies
19+
run: sudo apt update && sudo apt install -y build-essential libpng-dev
20+
21+
- name: Go Generate
22+
run: go generate -tags tools -x ./...
23+
24+
- name: golangci-lint
25+
uses: golangci/golangci-lint-action@v2
26+
27+
- name: Build
28+
run: go build -v -o api-linux-amd64 .
29+
env:
30+
CGO_ENABLED: 1

.github/workflows/release.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: self-hosted
12+
steps:
13+
- name: Set up Go
14+
uses: actions/setup-go@v2
15+
with:
16+
go-version: 1.17
17+
18+
- name: Check out code into the Go module directory
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Download dependencies
24+
run: sudo apt update && sudo apt install -y build-essential libpng-dev
25+
26+
- name: Run GoReleaser
27+
uses: goreleaser/goreleaser-action@v2
28+
with:
29+
version: latest
30+
args: release --rm-dist
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
34+
image:
35+
name: Image
36+
runs-on: self-hosted
37+
steps:
38+
- name: Check out code into the Go module directory
39+
uses: actions/checkout@v2
40+
with:
41+
fetch-depth: 0
42+
43+
- name: Login to GitHub Container Registry
44+
uses: docker/login-action@v1
45+
with:
46+
registry: ghcr.io
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Extract metadata (tags, labels) for Docker
51+
id: meta
52+
uses: docker/metadata-action@v3
53+
with:
54+
images: ghcr.io/${{ github.repository }}
55+
56+
- name: Set up Docker Buildx
57+
id: buildx
58+
uses: docker/setup-buildx-action@v1
59+
with:
60+
buildkitd-flags: --debug
61+
driver-opts: |
62+
network=host
63+
64+
- name: Build and push Docker image
65+
uses: docker/build-push-action@v2
66+
with:
67+
context: .
68+
push: true
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
build-args: |
72+
TARGET_ENV=${{ matrix.release }}

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
# Created by https://www.gitignore.io/api/go,jetbrains
3+
4+
### Go ###
5+
# Binaries for programs and plugins
6+
*.exe
7+
*.dll
8+
*.so
9+
*.dylib
10+
11+
# Test binary, build with `go test -c`
12+
*.test
13+
14+
# Output of the go coverage tool, specifically when used with LiteIDE
15+
*.out
16+
17+
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
18+
.glide/
19+
20+
### JetBrains ###
21+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
22+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
23+
24+
.idea/
25+
26+
# CMake
27+
cmake-build-debug/
28+
29+
## File-based project format:
30+
*.iws
31+
32+
## Plugin-specific files:
33+
34+
# IntelliJ
35+
/out/
36+
37+
# mpeltonen/sbt-idea plugin
38+
.idea_modules/
39+
40+
# JIRA plugin
41+
atlassian-ide-plugin.xml
42+
43+
# Cursive Clojure plugin
44+
.idea/replstate.xml
45+
46+
# Ruby plugin and RubyMine
47+
/.rakeTasks
48+
49+
# Crashlytics plugin (for Android Studio and IntelliJ)
50+
com_crashlytics_export_strings.xml
51+
crashlytics.properties
52+
crashlytics-build.properties
53+
fabric.properties
54+
55+
*.iml
56+
modules.xml
57+
*.ipr
58+
59+
# End of https://www.gitignore.io/api/go,jetbrains
60+
61+
config.json
62+
vendor/
63+
/docs/
64+
/paks/
65+
*.smod

.golangci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
linters-settings:
2+
wrapcheck:
3+
ignoreSigs:
4+
- .Errorf(
5+
- errors.New(
6+
- errors.Unwrap(
7+
- .Wrap(
8+
- .Wrapf(
9+
- .WithMessage(
10+
- .WithMessagef(
11+
- .WithStack(
12+
- github.com/labstack/echo/v4.Context
13+
14+
ignorePackageGlobs:
15+
- github.com/satisfactorymodding/smr-api/*
16+
17+
linters:
18+
disable-all: true
19+
enable:
20+
- deadcode
21+
- errcheck
22+
- gosimple
23+
- govet
24+
- ineffassign
25+
- staticcheck
26+
- structcheck
27+
- typecheck
28+
- unused
29+
- varcheck
30+
- bidichk
31+
- contextcheck
32+
- durationcheck
33+
- errorlint
34+
- goconst
35+
- goimports
36+
- revive
37+
- ifshort
38+
- misspell
39+
- prealloc
40+
- whitespace
41+
- wrapcheck

.goreleaser.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
before:
2+
hooks:
3+
- go mod download
4+
- go generate -tags tools -x ./...
5+
6+
builds:
7+
- env:
8+
- CGO_ENABLED=1
9+
goos:
10+
- linux
11+
goarch:
12+
- amd64
13+
binary: api
14+
main: ./cmd/api/serve.go
15+
16+
archives:
17+
- replacements:
18+
linux: Linux
19+
amd64: x86_64
20+
21+
checksum:
22+
name_template: 'checksums.txt'
23+
24+
snapshot:
25+
name_template: "{{ .Tag }}-next"
26+
27+
changelog:
28+
sort: asc
29+
filters:
30+
exclude:
31+
- '^docs:'
32+
- '^test:'

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM golang:1.17-alpine AS builder
2+
3+
RUN apk add --no-cache git build-base libpng-dev
4+
5+
WORKDIR $GOPATH/src/github.com/satisfactorymodding/smr-api/
6+
7+
ENV GO111MODULE=on
8+
9+
COPY go.mod go.mod
10+
COPY go.sum go.sum
11+
RUN go mod download
12+
13+
COPY . .
14+
15+
RUN go generate -tags tools -x ./...
16+
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -v -a -installsuffix cgo -o /go/bin/api cmd/api/serve.go
17+
18+
19+
FROM golang:alpine
20+
RUN apk add --no-cache libstdc++ libpng
21+
COPY --from=builder /go/bin/api /api
22+
WORKDIR /app
23+
COPY static /app/static
24+
COPY migrations /app/migrations
25+
EXPOSE 5020
26+
ENTRYPOINT ["/api"]

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SMR API
2+
3+
The Satisfactory Mod Repository backend API
4+
5+
## Running
6+
7+
Execute:
8+
9+
```bash
10+
go run cmd/api/serve.go
11+
```
12+
13+
### Configuration
14+
15+
Running the API has a lot of pre-requisites.
16+
17+
It is suggested you create a configuration file at `config.json` (but you can also use environment variables).
18+
19+
Main configuration options:
20+
21+
1. Postgres (started with `docker-compose -f docker-compose-dev.yml up -d`)
22+
2. Redis (started with `docker-compose -f docker-compose-dev.yml up -d`)
23+
3. S3 or B2
24+
4. GitHub OAuth (https://github.com/settings/developers)
25+
5. Google OAuth (https://console.developers.google.com/)
26+
6. Facebook OAuth (https://developers.facebook.com/apps/)
27+
7. Paseto keys (generated via `go run cmd/paseto/main.go`)
28+
8. Frontend URL (needed for Google OAuth, otherwise can be ignored)
29+
9. VirusTotal API key
30+
31+
The config format can be seen in `config/config.go` (each dot means a new level of nesting).

0 commit comments

Comments
 (0)