Skip to content

Commit 625b573

Browse files
committed
Added README
1 parent a04738a commit 625b573

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# go-server
2+
3+
This is an opinionated HTTP server which is designed to be used as a base for building
4+
API and web applications. It is designed to be extensible and modular, allowing you to add
5+
new features and functionality as needed. By default the server includes the following
6+
features:
7+
8+
* Authentication of users using JWT tokens and API keys
9+
* Connection to PostgreSQL databases
10+
* Task queues for running background jobs
11+
* Ability to manage the PostgreSQL database roles, databases, schemas and connections
12+
* Prometheus metrics support
13+
14+
The idea is that you can use this server as a base for your own applications, and add your own
15+
features and functionality as needed. More documentation soon on how to do that.
16+
17+
## Running
18+
19+
You can run the server in a docker container or build it from source. To run the latest
20+
released version as a docker container:
21+
22+
```bash
23+
docker run ghcr.io/mutablelogic/go-server:latest
24+
```
25+
26+
This will print out the help message.
27+
28+
## Building
29+
30+
### Download and build
31+
32+
```bash
33+
git clone github.com/mutablelogic/go-server
34+
cd go-server
35+
make
36+
```
37+
38+
The plugins and the `server` binary will be built in the `build` directory.
39+
40+
### Build requirements
41+
42+
You need the following three tools installed to build the server:
43+
44+
- [Go](https://golang.org/doc/install/source) (1.23 or later, not required for docker builds)
45+
- [Make](https://www.gnu.org/software/make/)
46+
- [Docker](https://docs.docker.com/get-docker/)
47+
- [NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
48+
49+
### Makefile targets
50+
51+
Binaries are placed in the `build` directory.
52+
53+
| Target | Description |
54+
|--------|-------------|
55+
| `make all` | Build all plugins and the server |
56+
| `make cmd/server` | Build the server binary |
57+
| `make plugins` | Build the server binary |
58+
| `make docker` | Build the docker container |
59+
| `make docker-push` | Push the docker container to remote repository, assuming logged in |
60+
| `make docker-version` | Prints out the docker container tag |
61+
| `make test` | Runs unit amd coverage tests |
62+
| `make unit-test` | Runs unit tests |
63+
| `VERBOSE=1 make unit-test` | Runs unit tests with verbose output |
64+
| `make coverage-test` | Reports code coverage |
65+
| `make tidy` | Runs go mod tidy |
66+
| `make clean` | Removes binaries and distribution files |
67+
68+
You can also affect the build by setting the following environment variables. For example,
69+
70+
```bash
71+
GOOS=linux GOARCH=amd64 make
72+
```
73+
74+
| Variable | Description |
75+
|----------|-------------|
76+
| `GOOS` | The target operating system for the build |
77+
| `GOARCH` | The target architecture for the build |
78+
| `BUILD_DIR` | The target architecture for the build |
79+
| `VERBOSE` | Setting this flag will provide verbose output for unit tests |
80+
| `VERSION` | Explicitly set the version |
81+
| `DOCKER_REPO` | The docker repository to push to. Defaults to `ghcr.io/mutablelogic/go-server` |
82+

etc/docker/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@ RUN apt update -y && apt install -y ca-certificates
2525
LABEL org.opencontainers.image.source=https://${SOURCE}
2626

2727
# Entrypoint when running the server
28-
ENV PLUGIN_PATH="/usr/local/bin/*.plugin"
28+
ENV \
29+
PLUGIN_PATH="/usr/local/bin/*.plugin" \
30+
ENDPOINT="http://0.0.0.0:80/"
31+
EXPOSE 80 443
2932
ENTRYPOINT [ "/usr/local/bin/server" ]

0 commit comments

Comments
 (0)