move scripts, allow testing both dbs with one cmd

This commit is contained in:
tsmethurst 2021-09-10 15:59:12 +02:00
commit 5510a39cf3
13 changed files with 263 additions and 99 deletions

View file

@ -34,9 +34,7 @@ steps:
environment:
GTS_DB_ADDRESS: postgres
commands:
# `-p 1` => run maximum one test at a time
# `./...` => run all tests
- go test -p 1 ./...
- ./scripts/test.sh
when:
event:
include:
@ -85,6 +83,6 @@ trigger:
---
kind: signature
hmac: 268d484fd9c5d14834a3e2a1e39cfe605c3898d601d2969dba5c2e11c1ea2f3b
hmac: 07325ed3186a319e5cf98f2307f04c4a10b01b2bd8fb394a2e633502041bfb90
...

View file

@ -1,4 +1,4 @@
# Contributing
# Contributing <!-- omit in toc -->
Hey! Welcome to the CONTRIBUTING.md for GoToSocial :) Thanks for taking a look, that kicks ass.
@ -8,6 +8,24 @@ Contributions are welcome at this point, since the API is fairly stable now and
Check the [issues](https://github.com/superseriousbusiness/gotosocial/issues) to see if there's anything you fancy jumping in on.
## Table Of Contents <!-- omit in toc -->
- [Communications](#communications)
- [Code of Conduct](#code-of-conduct)
- [Setting up your development environment](#setting-up-your-development-environment)
- [Golang forking quirks](#golang-forking-quirks)
- [Setting up your test environment](#setting-up-your-test-environment)
- [Standalone Testrig](#standalone-testrig)
- [Running tests](#running-tests)
- [SQLite](#sqlite)
- [Postgres](#postgres)
- [Both](#both)
- [Linting](#linting)
- [Updating Swagger docs](#updating-swagger-docs)
- [Pushing to Docker](#pushing-to-docker)
- [CI/CD configuration](#cicd-configuration)
- [Financial Compensation](#financial-compensation)
## Communications
Before starting on something, please comment on an issue to say that you're working on it, and/or drop into the GoToSocial Matrix room [here](https://matrix.to/#/#gotosocial:superseriousbusiness.org).
@ -28,7 +46,7 @@ To get started, you first need to have Go installed. GtS is currently using Go 1
Once you've got go installed, clone this repository into your Go path. Normally, this should be `~/go/src/github.com/superseriousbusiness/gotosocial`.
Once that's done, you can try building the project: `./build.sh`. This will build the `gotosocial` binary.
Once that's done, you can try building the project: `./scripts/build.sh`. This will build the `gotosocial` binary.
If there are no errors, great, you're good to go!
@ -76,12 +94,12 @@ One thing that *isn't* mocked is the Database interface, because it's just easie
You can also launch a testrig as a standalone server running at localhost, which you can connect to using something like [Pinafore](https://github.com/nolanlawson/pinafore).
To do this, first build the gotosocial binary with `./build.sh`.
To do this, first build the gotosocial binary with `./scripts/build.sh`.
Then, launch the testrig by invoking the binary as follows:
```bash
./gotosocial --host localhost:8080 testrig start
GTS_DB_TYPE="sqlite" GTS_DB_ADDRESS=":memory:" ./gotosocial --host localhost:8080 testrig start
```
To run Pinafore locally in dev mode, first clone the Pinafore repository, and run the following command in the cloned directory:
@ -104,13 +122,35 @@ Note the following constraints:
## Running tests
Because the tests use a real SQLite database under the hood, you can't run them in parallel, so you need to run tests with the following command:
There are a few different ways of running tests. Each requires the use of the `-p 1` flag, to indicate that they should not be run in parallel.
### SQLite
If you want to run tests as quickly as possible, using an SQLite in-memory database, use:
```bash
go test -p 1 ./...
GTS_DB_TYPE="sqlite" GTS_DB_ADDRESS=":memory:" go test -p 1 ./...
```
The `-p 1` flag means that only 1 test will be run at a time.
### Postgres
If you want to run tests against a Postgres database running on localhost, run:
```bash
GTS_DB_TYPE="postgres" GTS_DB_ADDRESS="localhost" go test -p 1 ./...
```
In the above command, it is assumed you are using the default Postgres password of `postgres`.
### Both
Finally, to run tests against both database types one after the other, use:
```bash
./scripts.test.sh
```
The above script is also used by the CI/CD runner to run tests.
## Linting
@ -140,6 +180,44 @@ golint ./internal/...
Then make sure to run `go fmt ./...` to update whitespace and other opinionated formatting.
## Updating Swagger docs
If you change swagger annotations on any of the API paths, you need to generate a new swagger file at `./docs/api/swagger.yaml`. You can do this with:
`./scripts/generateswagger.sh`
## Pushing to Docker
You can easily build a Docker container tagged with the current branch name using:
```bash
./scripts/dockerbuild.sh
```
Then, (assuming you have permissions to push to the [GoToSocial Docker repository](https://hub.docker.com/r/superseriousbusiness/gotosocial)), run:
```bash
./scripts/dockerpush.sh
```
Note: you should never manually push a Docker container from your machine to `latest` -- we have a CI/CD flow for that. Only push a Docker container manually when you're testing changes on a branch!
## CI/CD configuration
GoToSocial uses [Drone](https://www.drone.io/) for CI/CD tasks like running tests, linting, and building Docker containers. These runs are integrated with Github, and will be run on opening a pull request or merging into main.
The Drone instance for GoToSocial is [here](https://drone.superseriousbusiness.org/superseriousbusiness/gotosocial).
The `drone.yml` file is [here](./.drone.yml) -- this defines how and when Drone should run. Documentation for Drone is [here](https://docs.drone.io/).
Please note that the `drone.yml` file must be signed by the Drone admin account in order to be considered valid. This must be done every time the file is changed. This is to prevent tampering and hijacking of the Drone instance. See [here](https://docs.drone.io/signature/).
To sign the file, first install and setup the [drone cli tool](https://docs.drone.io/cli/install/). Then, run:
```bash
drone -t PUT_YOUR_DRONE_ADMIN_TOKEN_HERE -s https://drone.superseriousbusiness.org sign superseriousbusiness/gotosocial --save
```
## Financial Compensation
Right now there's no structure in place for financial compensation for pull requests and code. This is simply because there's no money being made on the project apart from the very small weekly Liberapay donations.

173
README.md
View file

@ -1,4 +1,4 @@
# GoToSocial
# GoToSocial <!-- omit in toc -->
![patrons](https://img.shields.io/liberapay/patrons/dumpsterqueer.svg?logo=liberapay) ![receives](https://img.shields.io/liberapay/receives/dumpsterqueer.svg?logo=liberapay)
@ -10,80 +10,109 @@ GoToSocial is an [ActivityPub](https://activitypub.rocks/) social network server
GoToSocial provides a lightweight, customizable, and safety-focused entryway into the [Fediverse](https://en.wikipedia.org/wiki/Fediverse), and is comparable to (but distinct from) existing projects such as [Mastodon](https://joinmastodon.org/), [Pleroma](https://pleroma.social/), [Friendica](https://friendica.net), and [PixelFed](https://pixelfed.org/).
With GoToSocial, you can keep in touch with your friends, post, read, and share images and articles, without being tracked or advertised to.
With GoToSocial, you can keep in touch with your friends, post, read, and share images and articles. All without being tracked or advertised to!
Documentation is at [docs.gotosocial.org](https://docs.gotosocial.org). You can skip straight to the API documentation [here](https://docs.gotosocial.org/en/latest/api/swagger/).
## Table of Contents <!-- omit in toc -->
- [Features](#features)
- [Federation](#federation)
- [Mastodon API compatible](#mastodon-api-compatible)
- [Granular post settings](#granular-post-settings)
- [Easy customizability for admins](#easy-customizability-for-admins)
- [Easy to run](#easy-to-run)
- [Safety + security features](#safety--security-features)
- [Various federation modes](#various-federation-modes)
- [OIDC integration](#oidc-integration)
- [Wishlist](#wishlist)
- [Design Ethos](#design-ethos)
- [Status](#status)
- [Getting Started](#getting-started)
- [Contributing](#contributing)
- [Contact](#contact)
- [Credits](#credits)
- [Image Attribution](#image-attribution)
- [Sponsorship + Funding](#sponsorship--funding)
- [License](#license)
## Features
### Federation
Because GoToSocial uses the [ActivityPub](https://activitypub.rocks/) protocol, you can hang out not just with people on your home server, but with people all over the [Fediverse](https://en.wikipedia.org/wiki/Fediverse), seamlessly.
Because GoToSocial uses [ActivityPub](https://activitypub.rocks/), you can hang out not just with people on your home server, but with people all over the [Fediverse](https://en.wikipedia.org/wiki/Fediverse), seamlessly.
Federation means that your home server is part of a network of servers all over the world that all communicate using the same protocol. Your data is no longer centralized on the servers of one gigantic corporation, but resides on your own server and is shared -- as you see fit -- across a resilient web of other home servers.
### Mastodon API compatible
Full support for modern, elegant apps like [Tusky](https://tusky.app/) and [Pinafore](https://pinafore.social/).
The Mastodon API has become the de-facto standard for client communication with federated servers, so GoToSocial has implemented and extended the API with custom functionality.
This means: full support for modern, beautiful apps like [Tusky](https://tusky.app/) and [Pinafore](https://pinafore.social/).
Tusky | Pinafore
:-----------------------------------------------------------:|:------------------------------------------------------------------:
![An image of GoToSocial in Tusky](./docs/assets/tusky.png) | ![An image of GoToSocial in Pinafore](./docs/assets/pinafore.png)
If you're used to using Mastodon, you'll find using GoToSocial a breeze.
### Granular post settings
You should be able to choose how your posts can be interacted with:
It's important that when you post something, you can choose who sees it.
* Local-only posts.
* Rebloggable/boostable toggle.
* 'Likeable' toggle.
* 'Replyable' toggle.
GoToSocial offers public/unlisted/friends-only/mutuals-only/and direct posts (slide in DMs!).
It also allows you to customize how people interact with your posts:
- Local-only posts.
- Rebloggable/boostable toggle.
- 'Likeable' toggle.
- 'Replyable' toggle.
### Easy customizability for admins
* Adjustable post length.
* Media upload size settings.
Lots of [config options](./example/config.yaml), including:
### LetsEncrypt
- Adjustable post length.
- Media upload size settings.
Built-in, automatic support for secure HTTPS with [LetsEncrypt](https://letsencrypt.org/).
### Easy to run
### Light footprint and good performance
No external dependencies apart from a database (or just use SQLite!). Simply download the binary + assets (or Docker container), and run.
Plays nice with lower-powered machines like Raspberry Pi, old laptops and tiny VPSes.
### Easy to deploy
### Safety + security features
No external dependencies apart from a database. Just download the binary + assets (or Docker container), and run.
### HTTP signature authentication
Protect your data.
### User Safety
Strict privacy enforcement for posts and strict blocking logic.
### Subscribeable and shareable allow/denylists for federation
Import and export allowlists and denylists. Subscribe to community-created blocklists (think Adblocker, but for federation!).
- Built-in, automatic support for secure HTTPS with [LetsEncrypt](https://letsencrypt.org/).
- Strict privacy enforcement for posts and strict blocking logic.
- Import and export allowlists and denylists. Subscribe to community-created blocklists (think Adblocker, but for federation!).
- HTTP signature authentication: GoToSocial requires [HTTP Signatures](https://tools.ietf.org/id/draft-cavage-http-signatures-01.html) when sending and receiving messages, to ensure that your messages can't be tampered with and your identity can't be forged.
### Various federation modes
* 'Normal' federation; discover new servers.
* Allowlist-only federation; choose which servers you talk to.
* Zero federation; keep your server private.
GoToSocial doesn't apply a one-size-fits-all approach to federation. Who your server federates with should be up to you.
- 'Normal' federation; discover new servers.
- Allowlist-only federation; choose which servers you talk to.
- Zero federation; keep your server private.
### OIDC integration
GoToSocial supports [OpenID Connect (OIDC)](https://openid.net/connect/) identity providers, meaning you can integrate it with existing user management services like [Auth0](https://auth0.com/), [Gitlab](https://docs.gitlab.com/ee/integration/openid_connect_provider.html), etc, or run your own and hook GtS up to that (we recommend [Dex](https://dexidp.io/)).
### Wishlist
These cool things will be implemented if time allows (because we really want them):
* **Groups** and group posting!
* Reputation-based 'slow' federation.
* Community decision making for federation and moderation actions.
* User-selectable custom templates for rendering public posts:
* Twitter-style
* Blogpost
* Gallery
* Etc.
- **Groups** and group posting!
- Reputation-based 'slow' federation.
- Community decision making for federation and moderation actions.
- User-selectable custom templates for rendering public posts:
- Twitter-style
- Blogpost
- Gallery
- Etc.
## Design Ethos
@ -121,38 +150,38 @@ For bugs and feature requests, please check to see if there's [already an issue]
The following libraries and frameworks are used by GoToSocial, with gratitude 💕
* [buckket/go-blurhash](https://github.com/buckket/go-blurhash); used for generating image blurhashes. [GPL-3.0 License](https://spdx.org/licenses/GPL-3.0-only.html).
* [coreos/go-oidc](https://github.com/coreos/go-oidc); OIDC client library. [Apache-2.0 License](https://spdx.org/licenses/Apache-2.0.html).
* [gin-gonic/gin](https://github.com/gin-gonic/gin); speedy router engine. [MIT License](https://spdx.org/licenses/MIT.html).
* [gin-contrib/cors](https://github.com/gin-contrib/cors); Gin CORS middleware. [MIT License](https://spdx.org/licenses/MIT.html).
* [gin-contrib/sessions](https://github.com/gin-contrib/sessions); Gin sessions middleware. [MIT License](https://spdx.org/licenses/MIT.html)
* [gin-contrib/static](https://github.com/gin-contrib/static); Gin static page middleware. [MIT License](https://spdx.org/licenses/MIT.html)
* [go-fed/activity](https://github.com/go-fed/activity); Golang ActivityPub/ActivityStreams library. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
* [go-fed/httpsig](https://github.com/go-fed/httpsig); secure HTTP signature library. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
* [google/uuid](https://github.com/google/uuid); UUID generation. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html)
* [go-playground/validator](https://github.com/go-playground/validator); struct validation. [MIT License](https://spdx.org/licenses/MIT.html)
* [gorilla/websocket](https://github.com/gorilla/websocket); Websocket connectivity. [BSD-2-Clause License](https://spdx.org/licenses/BSD-2-Clause.html).
* [h2non/filetype](https://github.com/h2non/filetype); filetype checking. [MIT License](https://spdx.org/licenses/MIT.html).
* [jackc/pgx](https://github.com/jackc/pgx); Postgres driver. [MIT License](https://spdx.org/licenses/MIT.html).
* [microcosm-cc/bluemonday](https://github.com/microcosm-cc/bluemonday); HTML user-input sanitization. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
* [mitchellh/mapstructure](https://github.com/mitchellh/mapstructure); Go interface => struct parsing. [MIT License](https://spdx.org/licenses/MIT.html).
* [modernc.org/sqlite](https://gitlab.com/cznic/sqlite); cgo-free port of SQLite. [Other License](https://gitlab.com/cznic/sqlite/-/blob/master/LICENSE).
* [modernc.org/ccgo](https://gitlab.com/cznic/ccgo); c99 AST -> Go translater. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
* [modernc.org/libc](https://gitlab.com/cznic/libc); C-runtime services. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
* [mvdan/xurls](https://github.com/mvdan/xurls); URL parsing regular expressions. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
* [nfnt/resize](https://github.com/nfnt/resize); convenient image resizing. [ISC License](https://spdx.org/licenses/ISC.html).
* [oklog/ulid](https://github.com/oklog/ulid); sequential, database-friendly ID generation. [Apache-2.0 License](https://spdx.org/licenses/Apache-2.0.html).
* [ReneKroon/ttlcache](https://github.com/ReneKroon/ttlcache); in-memory caching. [MIT License](https://spdx.org/licenses/MIT.html).
* [russross/blackfriday](https://github.com/russross/blackfriday); markdown parsing for statuses. [Simplified BSD License](https://spdx.org/licenses/BSD-2-Clause.html).
* [sirupsen/logrus](https://github.com/sirupsen/logrus); logging. [MIT License](https://spdx.org/licenses/MIT.html).
* [stretchr/testify](https://github.com/stretchr/testify); test framework. [MIT License](https://spdx.org/licenses/MIT.html).
* [superseriousbusiness/exifremove](https://github.com/superseriousbusiness/exifremove) forked from [scottleedavis/go-exif-remove](https://github.com/scottleedavis/go-exif-remove); EXIF data removal. [MIT License](https://spdx.org/licenses/MIT.html).
* [superseriousbusiness/oauth2](https://github.com/superseriousbusiness/oauth2) forked from [go-oauth2/oauth2](https://github.com/go-oauth2/oauth2); oauth server framework and token handling. [MIT License](https://spdx.org/licenses/MIT.html).
* [go-swagger/go-swagger](https://github.com/go-swagger/go-swagger); Swagger OpenAPI spec generation. [Apache-2.0 License](https://spdx.org/licenses/Apache-2.0.html).
* [tdewolff/minify](https://github.com/tdewolff/minify); HTML minification. [MIT License](https://spdx.org/licenses/MIT.html).
* [uptrace/bun](https://github.com/uptrace/bun); database ORM. [BSD-2-Clause License](https://spdx.org/licenses/BSD-2-Clause.html).
* [urfave/cli](https://github.com/urfave/cli); command-line interface framework. [MIT License](https://spdx.org/licenses/MIT.html).
* [wagslane/go-password-validator](https://github.com/wagslane/go-password-validator); password strength validation. [MIT License](https://spdx.org/licenses/MIT.html).
- [buckket/go-blurhash](https://github.com/buckket/go-blurhash); used for generating image blurhashes. [GPL-3.0 License](https://spdx.org/licenses/GPL-3.0-only.html).
- [coreos/go-oidc](https://github.com/coreos/go-oidc); OIDC client library. [Apache-2.0 License](https://spdx.org/licenses/Apache-2.0.html).
- [gin-gonic/gin](https://github.com/gin-gonic/gin); speedy router engine. [MIT License](https://spdx.org/licenses/MIT.html).
- [gin-contrib/cors](https://github.com/gin-contrib/cors); Gin CORS middleware. [MIT License](https://spdx.org/licenses/MIT.html).
- [gin-contrib/sessions](https://github.com/gin-contrib/sessions); Gin sessions middleware. [MIT License](https://spdx.org/licenses/MIT.html)
- [gin-contrib/static](https://github.com/gin-contrib/static); Gin static page middleware. [MIT License](https://spdx.org/licenses/MIT.html)
- [go-fed/activity](https://github.com/go-fed/activity); Golang ActivityPub/ActivityStreams library. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
- [go-fed/httpsig](https://github.com/go-fed/httpsig); secure HTTP signature library. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
- [google/uuid](https://github.com/google/uuid); UUID generation. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html)
- [go-playground/validator](https://github.com/go-playground/validator); struct validation. [MIT License](https://spdx.org/licenses/MIT.html)
- [gorilla/websocket](https://github.com/gorilla/websocket); Websocket connectivity. [BSD-2-Clause License](https://spdx.org/licenses/BSD-2-Clause.html).
- [h2non/filetype](https://github.com/h2non/filetype); filetype checking. [MIT License](https://spdx.org/licenses/MIT.html).
- [jackc/pgx](https://github.com/jackc/pgx); Postgres driver. [MIT License](https://spdx.org/licenses/MIT.html).
- [microcosm-cc/bluemonday](https://github.com/microcosm-cc/bluemonday); HTML user-input sanitization. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
- [mitchellh/mapstructure](https://github.com/mitchellh/mapstructure); Go interface => struct parsing. [MIT License](https://spdx.org/licenses/MIT.html).
- [modernc.org/sqlite](https://gitlab.com/cznic/sqlite); cgo-free port of SQLite. [Other License](https://gitlab.com/cznic/sqlite/-/blob/master/LICENSE).
- [modernc.org/ccgo](https://gitlab.com/cznic/ccgo); c99 AST -> Go translater. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
- [modernc.org/libc](https://gitlab.com/cznic/libc); C-runtime services. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
- [mvdan/xurls](https://github.com/mvdan/xurls); URL parsing regular expressions. [BSD-3-Clause License](https://spdx.org/licenses/BSD-3-Clause.html).
- [nfnt/resize](https://github.com/nfnt/resize); convenient image resizing. [ISC License](https://spdx.org/licenses/ISC.html).
- [oklog/ulid](https://github.com/oklog/ulid); sequential, database-friendly ID generation. [Apache-2.0 License](https://spdx.org/licenses/Apache-2.0.html).
- [ReneKroon/ttlcache](https://github.com/ReneKroon/ttlcache); in-memory caching. [MIT License](https://spdx.org/licenses/MIT.html).
- [russross/blackfriday](https://github.com/russross/blackfriday); markdown parsing for statuses. [Simplified BSD License](https://spdx.org/licenses/BSD-2-Clause.html).
- [sirupsen/logrus](https://github.com/sirupsen/logrus); logging. [MIT License](https://spdx.org/licenses/MIT.html).
- [stretchr/testify](https://github.com/stretchr/testify); test framework. [MIT License](https://spdx.org/licenses/MIT.html).
- [superseriousbusiness/exifremove](https://github.com/superseriousbusiness/exifremove) forked from [scottleedavis/go-exif-remove](https://github.com/scottleedavis/go-exif-remove); EXIF data removal. [MIT License](https://spdx.org/licenses/MIT.html).
- [superseriousbusiness/oauth2](https://github.com/superseriousbusiness/oauth2) forked from [go-oauth2/oauth2](https://github.com/go-oauth2/oauth2); oauth server framework and token handling. [MIT License](https://spdx.org/licenses/MIT.html).
- [go-swagger/go-swagger](https://github.com/go-swagger/go-swagger); Swagger OpenAPI spec generation. [Apache-2.0 License](https://spdx.org/licenses/Apache-2.0.html).
- [tdewolff/minify](https://github.com/tdewolff/minify); HTML minification. [MIT License](https://spdx.org/licenses/MIT.html).
- [uptrace/bun](https://github.com/uptrace/bun); database ORM. [BSD-2-Clause License](https://spdx.org/licenses/BSD-2-Clause.html).
- [urfave/cli](https://github.com/urfave/cli); command-line interface framework. [MIT License](https://spdx.org/licenses/MIT.html).
- [wagslane/go-password-validator](https://github.com/wagslane/go-password-validator); password strength validation. [MIT License](https://spdx.org/licenses/MIT.html).
### Image Attribution
@ -166,6 +195,6 @@ If you want to sponsor this project, you can do so [here](https://liberapay.com/
## License
GoToSocial is licensed under the [GNU AGPL v3 LICENSE](LICENSE).
GoToSocial is free software, licensed under the [GNU AGPL v3 LICENSE](LICENSE).
Copyright (C) 2021 the GoToSocial Authors.

View file

@ -1,3 +0,0 @@
#!/bin/bash
docker build -t "superseriousbusiness/gotosocial:$(git rev-parse --abbrev-ref HEAD)" .

View file

@ -1,3 +0,0 @@
#!/bin/bash
docker push "superseriousbusiness/gotosocial:$(git rev-parse --abbrev-ref HEAD)"

View file

@ -1,7 +1,24 @@
# Quick and Dirty
# Quick and Dirty <!-- omit in toc -->
This is the quick and dirty getting started guide. It's not recommended to run GtS like this in production, but if you want to quickly get a server up and running, this is a good way to do it.
## Table of Contents <!-- omit in toc -->
- [1: Domain Name](#1-domain-name)
- [2: VPS](#2-vps)
- [3: DNS](#3-dns)
- [4: Postgres](#4-postgres)
- [5: Build the Binary](#5-build-the-binary)
- [6: Prepare VPS](#6-prepare-vps)
- [7: Copy Binary](#7-copy-binary)
- [8: Copy Web Dir](#8-copy-web-dir)
- [9: Run the Binary](#9-run-the-binary)
- [10: Create and confirm your user](#10-create-and-confirm-your-user)
- [Create](#create)
- [Confirm](#confirm)
- [Promote](#promote)
- [11. Login](#11-login)
## 1: Domain Name
Get a domain name -- [Namecheap](https://www.namecheap.com/) is a good place to do this, but you can use any domain name registrar that lets you manage your own DNS.
@ -12,6 +29,8 @@ Spin yourself up a cheap VPS with Linux running on it, or get a homeserver ready
[Hostwinds](https://www.hostwinds.com/) is a good option here: it's cheap and they throw in a static IP address for free.
[Greenhost](https://greenhost.net) is also great: it has zero co2 emissions, but is a bit more costly.
This guide won't go into running [UFW](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-18-04) and [Fail2Ban](https://linuxize.com/post/install-configure-fail2ban-on-ubuntu-20-04/) but you absolutely should do that. Leave ports `443` and `80` open.
## 3: DNS
@ -25,7 +44,7 @@ Install [Postgres](https://www.postgresql.org/download/) on your server and run
If you have [Docker](https://docs.docker.com/engine/install/ubuntu/) installed on your server, this is as easy as running:
```bash
docker run -d --network host --user postgres -e POSTGRES_PASSWORD=some_password postgres
docker run -d --network host --user postgres -e POSTGRES_PASSWORD=some_password postgres
```
## 5: Build the Binary
@ -33,13 +52,13 @@ docker run -d --network host --user postgres -e POSTGRES_PASSWORD=some_password
On your local machine (not your server), with Go installed, clone the GoToSocial repository, and build the binary with the provided build script:
```bash
./build.sh
./scripts/build.sh
```
If you need to build for a different architecture other than the one you're running the build on (eg., you're running on a Raspberry Pi but building on an amd64 machine), you can put set `GOOS` or `GOARCH` environment variables before running the build script, eg:
```bash
GOARCH=arm64 ./build.sh
GOARCH=arm64 ./scripts/build.sh
```
## 6: Prepare VPS
@ -70,7 +89,7 @@ scp -r ./web root@example.org:/gotosocial/
## 9: Run the Binary
Everything is in place now.
You can now run the binary.
First cd into the directory you created on your remote machine in step 6:
@ -122,6 +141,6 @@ If you want your user to have admin rights, you can promote them using a similar
Replace `example.org` with your domain and `some_username` with the username of the account you just created.
## 11. Login!
## 11. Login
You should now be able to log in to your instance using the email address and password of the account you just created. We recommend using [Pinafore](https://pinafore.social) or Tusky for this.
You should now be able to log in to your instance using the email address and password of the account you just created. We recommend using [Pinafore](https://pinafore.social) or [Tusky](https://tusky.app) for this.

View file

@ -1,3 +0,0 @@
#!/bin/bash
golangci-lint run --test=false

7
scripts/dockerbuild.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
set -eu
BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
docker build -t "superseriousbusiness/gotosocial:${BRANCH_NAME}" .

7
scripts/dockerpush.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
set -e
BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
docker push "superseriousbusiness/gotosocial:${BRANCH_NAME}"

View file

@ -1,5 +1,7 @@
#!/bin/bash
set -eu
SWAGGER_FILE="docs/api/swagger.yaml"
GTS_VERSION="$(cat version)"

12
scripts/test.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/sh
set -e
# "./..." = all tests
# "-p 1" = run with parallel value of 1 -- in other words, one test at a time
# run tests with sqlite in-memory database
GTS_DB_TYPE="sqlite" GTS_DB_ADDRESS=":memory:" go test -p 1 ./...
# run tests with postgres database at either GTS_DB_ADDRESS or default localhost
GTS_DB_TYPE="postgres" GTS_DB_ADDRESS="${GTS_DB_ADDRESS:-localhost}" go test -p 1 ./...

View file

@ -21,6 +21,7 @@ package testrig
import (
"context"
"os"
"strconv"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/db"
@ -58,6 +59,12 @@ var testModels []interface{} = []interface{}{
//
// If the environment variable GTS_DB_ADDRESS is set, it will take that
// value as the database address instead.
//
// If the environment variable GTS_DB_TYPE is set, it will take that
// value as the database type instead.
//
// If the environment variable GTS_DB_PORT is set, it will take that
// value as the port instead.
func NewTestDB() db.DB {
config := NewTestConfig()
alternateAddress := os.Getenv("GTS_DB_ADDRESS")
@ -65,6 +72,20 @@ func NewTestDB() db.DB {
config.DBConfig.Address = alternateAddress
}
alternateDBType := os.Getenv("GTS_DB_TYPE")
if alternateDBType != "" {
config.DBConfig.Type = alternateDBType
}
alternateDBPort := os.Getenv("GTS_DB_PORT")
if alternateDBPort != "" {
port, err := strconv.ParseInt(alternateDBPort, 10, 64)
if err != nil {
panic(err)
}
config.DBConfig.Port = int(port)
}
testDB, err := bundb.NewBunDBService(context.Background(), config, NewTestLog())
if err != nil {
logrus.Panic(err)