1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
---
title: "Building and Testing"
description: "Building and Testing Authelia."
lead: "This section covers the build process and how to perform tests in development."
date: 2022-06-15T17:51:47+10:00
draft: false
images: []
menu:
contributing:
parent: "development"
weight: 240
toc: true
aliases:
- /docs/contributing/build-and-dev.html
---
__Authelia__ is built a [React] frontend user portal bundled in a [Go] application which acts as a basic webserver for
the [React] assets and a dedicated API.
The GitHub repository comes with a CLI dedicated to developers called
[authelia-scripts](reference-authelia-scripts.md) which can be setup by looking at
[Reference: authelia-scripts](reference-authelia-scripts.md).
In order to build and contribute to __Authelia__, you need to make sure that you have looked at the
[Environment](environment.md) guide to configure your development environment.
## Get started
In order to ease development, __Authelia__ uses the concept of [suites] to run Authelia from source code so that your
patches are included. This is a kind of virtual environment running __Authelia__ in a complete ecosystem
(LDAP, Redis, SQL server). Note that __Authelia__ is hot-reloaded in the environment so that your patches are instantly
included.
The next command starts the suite called *Standalone*:
```bash
authelia-scripts suites setup Standalone
```
Most of the suites are using docker-compose to bootstrap the environment. Therefore, you can check the logs of all
application by running the following command on the component you want to monitor.
```bash
docker logs authelia_authelia-backend_1 -f
```
Then, edit the code and observe how __Authelia__ is automatically reloaded.
### Unit tests
To run the unit tests, run:
```bash
authelia-scripts unittest
```
### Integration tests
Integration tests are located under the `internal/suites` directory and are based on Selenium. A suite is a combination
of environment and tests. Executing a suite therefore means starting the environment, running the tests and tearing down
the environment. Each step can be run independently:
```bash
# List the available suites
$ authelia-scripts suites list
Standalone
DuoPush
LDAP
Traefik
# Start the environment of Standalone suite.
$ authelia-scripts suites setup Standalone
# Run the tests related to the currently running suite.
$ authelia-scripts suites test
# Tear down the environment
$ authelia-scripts suites teardown Standalone
```
In order to test all suites (approx 30 minutes), you need to make sure there is no currently running sui te and then you
should run:
```bash
authelia-scripts suites test
```
Also, you don't need to start the suite before testing it. Given you're not running any suite, just use the following
command to test the *Standalone* suite.
```bash
authelia-scripts suites test Standalone
```
The suite will be spawned, tests will be run and then the suite will be torn down automatically.
## Manually Building
### Binary
If you want to manually build the binary from source you will require the open source software described in the
[Development Environment](./environment.md#setup) documentation. Then you can follow the below steps on Linux (you may
have to adapt them on other systems).
Clone the Repository:
```bash
git clone https://github.com/authelia/authelia.git
```
Download the Dependencies:
```bash
cd authelia && go mod download
cd web && pnpm install
cd ..
```
Build the Web Frontend:
```bash
cd web && pnpm build
cd ..
cp -r api internal/server/public_html/api
```
Build the Binary (with debug symbols):
```bash
CGO_ENABLED=1 CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong" CGO_LDFLAGS="-Wl,-z,relro,-z,now" \
go build -ldflags "-linkmode=external" -trimpath -buildmode=pie -o authelia ./cmd/authelia
```
Build the Binary (without debug symbols):
```bash
CGO_ENABLED=1 CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong" CGO_LDFLAGS="-Wl,-z,relro,-z,now" \
go build -ldflags "-linkmode=external -s -w" -trimpath -buildmode=pie -o authelia ./cmd/authelia
```
[suites]: ./integration-suites.md
[React]: https://reactjs.org/
[go]: https://go.dev/dl/
[Node.js]: https://nodejs.org/en/download/
[Docker]: https://docs.docker.com/get-docker/
[Docker Compose]: https://docs.docker.com/compose/install/
[golangci-lint]: https://golangci-lint.run/usage/install/
[goimports-reviser]: https://github.com/incu6us/goimports-reviser#install
|