Skip to content

Commit 00ac434

Browse files
authored
Add self hosted installation guide to docs (th0th#189)
* Create the file * Add self-hosting guide * Add the self-hosted guide link to README
1 parent e7d80a6 commit 00ac434

File tree

3 files changed

+167
-18
lines changed

3 files changed

+167
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ The quickest way to start using PoeticMetric is, [signing up on the managed serv
2828

2929
### Self-hosted
3030

31-
PoeticMetric is 100% open source. This means, you can run your own instance of PoeticMetric on your own servers. In order to simplify self-hosting process, I also built required docker images, and prepared a sample configuration.
31+
PoeticMetric is a 100% open source website analytics tool. This means, you can run your own instance of PoeticMetric on your own servers. In order to simplify self-hosting process, I also built required docker images, and prepared a sample configuration.
3232

33-
I am planning to write a self-hosted installation guide in the future. But for now, you can check out the [`docker-compose.yaml` file in the `self-hosted`](self-hosted/docker-compose.yaml) directory. [You can also find an example `.env` file there](self-hosted/.env.example).
33+
You can read the guide on how to self-host your PoeticMetric instance on [PoeticMetric docs](https://www.poeticmetric.com/docs/open-source/self-hosting).
3434

3535
## Sponsoring
3636

frontend/components/Markdown/Markdown.module.scss

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@
1313
}
1414
}
1515

16+
blockquote {
17+
background-color: $gray-100;
18+
border-left: 0.375rem solid $blue;
19+
font-style: italic;
20+
font-weight: $font-weight-medium;
21+
margin-block: 1rem;
22+
padding: 0.5rem 1rem;
23+
}
24+
1625
figure {
17-
margin: 16px auto;
26+
margin: 1rem auto;
1827

1928
img {
20-
margin: 0 auto;
2129
border: 1px solid $gray-200;
2230
border-radius: $border-radius;
2331
display: block;
32+
margin: 0 auto;
2433
max-width: 100%;
2534
}
2635

@@ -31,13 +40,10 @@
3140
}
3241
}
3342

34-
blockquote {
35-
background-color: $gray-100;
36-
border-left: 0.375rem solid $blue;
37-
font-style: italic;
38-
font-weight: $font-weight-medium;
39-
margin-block: 1rem;
40-
padding: 0.5rem 1rem;
43+
h2, h3, h4, h5 {
44+
code {
45+
color: inherit;
46+
}
4147
}
4248

4349
h2 {
@@ -65,12 +71,12 @@
6571
border-radius: $border-radius;
6672
counter-reset: list;
6773
list-style: none;
68-
margin: 16px 0;
69-
padding: 16px;
74+
margin: 1rem 0;
75+
padding: 1rem;
7076

7177
> li {
7278
counter-increment: list;
73-
padding-left: 36px;
79+
padding-left: 2.25rem;
7480
position: relative;
7581

7682
&:before {
@@ -81,16 +87,16 @@
8187
content: counter(list);
8288
display: flex;
8389
flex-direction: column;
84-
font-size: 14px;
90+
font-size: $font-size-sm;
8591
font-weight: 700;
86-
height: 24px;
92+
height: 1.5rem;
8793
justify-content: center;
8894
left: 0;
89-
margin-top: 4px;
95+
margin-top: 0.25rem;
9096
position: absolute;
9197
text-align: center;
9298
top: 0;
93-
width: 24px;
99+
width: 1.5rem;
94100
}
95101
}
96102
}
@@ -108,4 +114,33 @@
108114
max-width: 100%;
109115
}
110116
}
117+
118+
pre {
119+
code {
120+
border-radius: $border-radius;
121+
}
122+
}
123+
124+
table {
125+
border-collapse: collapse;
126+
width: 100%;
127+
128+
tr {
129+
&:nth-child(2n) {
130+
background-color: $gray-100;
131+
}
132+
133+
td, th {
134+
border: 1px solid $gray-400;
135+
padding: 0.25rem 0.5rem;
136+
}
137+
138+
td {
139+
}
140+
141+
th {
142+
font-weight: $font-weight-bold;
143+
}
144+
}
145+
}
111146
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
title: Self-hosting
3+
---
4+
5+
You can get your own PoeticMetric Analytics self-hosted website analytics instance up and running in minutes following this guide. It doesn't require any software development expertise, if you are a little tech-savvy you can do it. PoeticMetric is designed to be self-hosted with Docker, and ready-to-use Docker images are published publicly.
6+
7+
<!-- end -->
8+
9+
If you are curious, there is another documentation article that explains about the parts of PoeticMetric and how these parts communicate with each other. You can check the technical architecture documentation [here](/docs/open-source/technical-architecture).
10+
11+
## Requirements
12+
13+
You will need a server with Docker installed. PoeticMetric has Docker images prebuilt for architectures `linux/amd64` and `linux/arm64`, so make sure your servers CPU is either `x86-64` or `arm64`.
14+
15+
PoeticMetric can run successfully on memory as low as 2GB, however, we recommend allocating at least 4GB of RAM for a smoother experience. However, keep in mind that as the traffic of your website goes up, you might need a more powerful server with a more powerful CPU and more RAM.
16+
17+
<Alert variant="primary">
18+
If you don't have a server, you can check it out [Hetzner Cloud](https://hetzner.cloud/?ref=IOqhEJnmxLGq) (referral link), we run our servers on their infrastructure, and we can recommend!
19+
</Alert>
20+
21+
## Versions
22+
23+
When you follow this tutorial, you will be deploying the latest stable version of PoeticMetric. However, a new version of PoeticMetric will be released with new features from time to time. Don't forget to check the section [Updating to a new version](#updating) before you leave.
24+
25+
PoeticMetric Analytics uses [semantic versioning](https://semver.org): `MAJOR.MINOR.PATCH`
26+
27+
* Updates with a `PATCH` version change (e.g. from `v1.0.0` to `v1.0.1`) include small changes, and mostly, bug fixes.
28+
* `MINOR` version changing updates (e.g. from `v1.0.8` to `v1.1.0`) include new features, in a backward compatible manner.
29+
* `MAJOR` version updates include big and important changes, most probably backward incompatible.
30+
31+
Even tough we suggest backing up your data periodically, and especially before performing an update, if you are going for a major version change, please pay extra attention to data backups.
32+
33+
## Running
34+
35+
### Downloading
36+
37+
Start by downloading the required Docker Compose configuration. Download the `self-hosted.zip` file for the [latest release](https://github.com/th0th/poeticmetric/releases/latest), and unzip it:
38+
39+
```shell
40+
$ curl -fsSL https://github.com/th0th/poeticmetric/releases/latest/download/self-hosted.tar.gz | tar -xz
41+
$ cd poeticmetric
42+
```
43+
44+
### Set environment variables
45+
46+
You will find an `.env.example` file that has all the required environment variables with their default values. First, make a copy of this file with the actual file name:
47+
48+
```shell
49+
$ cp .env.example .env
50+
```
51+
52+
You can leave most of them as they are, however, you will need to change some of them:
53+
54+
#### Internal passwords
55+
56+
These variables will be used for setting the password the relevant component on the first run:
57+
58+
* `CLICKHOUSE_PASSWORD`
59+
* `POSTGRES_PASSWORD`
60+
* `RABBITMQ_PASSWORD`
61+
* `REDIS_PASSWORD`
62+
63+
So, pick a **different**, hard to guess password for each one, and make sure you make note of these. Normally, you won't use any of these passwords while using PoeticMetric. However, if you face any issue, you will need each of them. If you lose one of these passwords, your databases may become inaccessible, and you might lose data.
64+
65+
#### Google Search Console integration variables
66+
67+
`GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` are required only for [Google Search Console integration](https://dev.poeticmetric.com/docs/websites/google-search-console-integration). If you are planning to use the integration, you need to obtain them from [Google](https://developers.google.com/webmaster-tools). If you are not planning to use, you can safely skip and leave them as empty. You can also update these variables later.
68+
69+
#### URLs
70+
71+
PoeticMetric has two components that are accessible by HTTP:
72+
73+
* Frontend (`FRONTEND_BASE_URL`)
74+
* REST API (`REST_API_BASE_URL`)
75+
76+
By the default `docker-compose.yaml`, frontend uses the port `8000`, and REST API `8001`. If you are not going to use a domain name, or a reverse proxy, you should set these as:
77+
78+
`FRONTEND_BASE_URL=http://<your_server_ip_address>:8000`
79+
80+
and
81+
82+
`REST_API_BASE_URL=http://<your_server_ip_address>:8001`
83+
84+
If you are going to use a reverse proxy with a domain name, you need to update the variables `FRONTEND_BASE_URL` and `REST_API_BASE_URL` accordingly, and configure two different virtual servers on your reverse proxy. One for the frontend, pointing to the port `8000`; and another one for the REST API, pointing to the port `8001`.
85+
86+
#### SMTP variables
87+
88+
PoeticMetric requires [Simple Mail Transfer Protocol (SMTP)](https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol) for delivering e-mails that are used for notifications, password recovery etc.
89+
90+
Set `SMTP_FROM`, `SMTP_HOST`, `SMTP_PASSWORD`, `SMTP_PORT` and `SMTP_USER` variables according to your e-mail service provider.
91+
92+
### Running services
93+
94+
Once you are done setting up your environment variables, you can bring PoeticMetric's services up by:
95+
96+
```shell
97+
$ docker compose up -d
98+
```
99+
100+
If everything goes well, you should be able to access your self-hosted website analytics instance via the frontend URL you set in the [URLs](#urls) step. Go to `http://<your_frontend_base_url>/bootstrap` to initialize the database schemas, and create your account.
101+
102+
## Updating
103+
104+
When a fresh edition of PoeticMetric becomes available, simply follow these steps: temporarily halt PoeticMetric's services, retrieve the latest docker images, and restart the services. PoeticMetric takes care of updating the databases automatically whenever necessary.
105+
106+
```shell
107+
$ docker compose down --remove-orphans
108+
$ docker compose pull
109+
$ docker compose up -d
110+
```
111+
112+
## Getting help
113+
114+
If you have any issues setting up your PoeticMetric Analytics instance, you can ask for community members' help on [GitHub Discussions](https://github.com/th0th/poeticmetric/discussions/new?category=self-hosted-help).

0 commit comments

Comments
 (0)