@@ -15,7 +15,6 @@ update_os
1515
1616msg_info " Installing Dependencies (Patience)"
1717$STD apt-get install -y \
18- gpg \
1918 pkg-config \
2019 libffi-dev \
2120 build-essential \
@@ -33,9 +32,15 @@ $STD apt-get install -y \
3332 libxmlsec1-openssl \
3433 libmaxminddb0 \
3534 python3-pip \
35+ redis-server \
3636 git
3737msg_ok " Installed Dependencies"
3838
39+ setup_uv
40+ PG_VERSION=" 16" install_postgresql
41+ NODE_VERSION=" 22" install_node_and_modules
42+ install_go
43+
3944msg_info " Installing yq"
4045cd /tmp
4146YQ_LATEST=" $( curl -fsSL https://api.github.com/repos/mikefarah/yq/releases/latest | grep -Po ' "tag_name": "\K.*?(?=")' ) "
@@ -56,46 +61,8 @@ cat <<EOF >/etc/GeoIP.conf
5661EOF
5762msg_ok " Installed GeoIP"
5863
59- msg_info " Setting up Python 3"
60- cd /tmp
61- curl -fsSL " https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tgz" -o " Python.tgz"
62- tar -zxf Python.tgz
63- cd Python-3.12.1
64- $STD ./configure --enable-optimizations
65- $STD make altinstall
66- cd ~
67- $STD update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.12 1
68- msg_ok " Setup Python 3"
69-
70- msg_info " Setting up Node.js Repository"
71- mkdir -p /etc/apt/keyrings
72- curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
73- echo " deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" > /etc/apt/sources.list.d/nodesource.list
74- msg_ok " Set up Node.js Repository"
75-
76- msg_info " Installing Node.js"
77- $STD apt-get update
78- $STD apt-get install -y nodejs
79- msg_ok " Installed Node.js"
80-
81- msg_info " Installing Golang"
82- set +o pipefail
83- temp_file=$( mktemp)
84- golang_tarball=$( curl -fsSL https://go.dev/dl/ | grep -oP ' go[\d\.]+\.linux-amd64\.tar\.gz' | head -n 1)
85- curl -fsSL " https://golang.org/dl/${golang_tarball} " -o " $temp_file "
86- tar -C /usr/local -xzf " $temp_file "
87- ln -sf /usr/local/go/bin/go /usr/local/bin/go
88- rm -f " $temp_file "
89- set -o pipefail
90- msg_ok " Installed Golang"
91-
92- msg_info " Installing Redis"
93- $STD apt-get install -y redis-server
94- systemctl enable -q --now redis-server
95- msg_ok " Installed Redis"
96-
9764msg_info " Installing PostgreSQL"
98- $STD apt-get install -y postgresql postgresql-contrib
65+ $STD apt-get install -y postgresql-16 postgresql-contrib-16
9966DB_NAME=" authentik"
10067DB_USER=" authentik"
10168DB_PASS=" $( openssl rand -base64 18 | cut -c1-13) "
@@ -111,71 +78,110 @@ RELEASE=$(curl -fsSL https://api.github.com/repos/goauthentik/authentik/releases
11178mkdir -p /opt/authentik
11279curl -fsSL " ${RELEASE} " -o " authentik.tar.gz"
11380tar -xzf authentik.tar.gz -C /opt/authentik --strip-components 1 --overwrite
81+ export NODE_OPTIONS=" --max-old-space-size=4096"
11482cd /opt/authentik/website
11583$STD npm install
11684$STD npm run build-bundled
85+
11786cd /opt/authentik/web
11887$STD npm install
11988$STD npm run build
120- echo " ${RELEASE} " > /opt/ ${APPLICATION} _version.txt
89+
12190cd /opt/authentik
12291$STD go mod download
12392$STD go build -o /go/authentik ./cmd/server
12493$STD go build -o /opt/authentik/authentik-server /opt/authentik/cmd/server/
125- cd /opt/authentik
126- $STD pip3 install --upgrade pip
127- $STD pip3 install poetry poetry-plugin-export
128- ln -s /usr/local/bin/poetry /usr/bin/poetry
129- $STD poetry install --only=main --no-ansi --no-interaction --no-root
130- $STD poetry export --without-hashes --without-urls -f requirements.txt --output requirements.txt
131- $STD pip install --no-cache-dir -r requirements.txt
132- $STD pip install .
94+ $STD uv sync --frozen --no-install-project --no-dev
95+ # $STD pip3 install --no-cache-dir --upgrade pip
96+ # $STD pip3 install --upgrade pip
97+ # $STD pip3 install poetry poetry-plugin-export
98+
99+ # ln -s /usr/local/bin/poetry /usr/bin/poetry
100+ # $STD poetry install --only=main --no-ansi --no-interaction --no-root
101+ # $STD poetry export --without-hashes --without-urls -f requirements.txt --output requirements.txt
102+ # $STD pip install --no-cache-dir -r requirements.txt
103+ # $STD pip install .
133104mkdir -p /etc/authentik
134105mv /opt/authentik/authentik/lib/default.yml /etc/authentik/config.yml
135106$STD yq -i " .secret_key = \" $( openssl rand -hex 32) \" " /etc/authentik/config.yml
136107$STD yq -i " .postgresql.password = \" ${DB_PASS} \" " /etc/authentik/config.yml
137108$STD yq -i " .geoip = \" /opt/authentik/tests/GeoLite2-City-Test.mmdb\" " /etc/authentik/config.yml
138109cp -r /opt/authentik/authentik/blueprints /opt/authentik/blueprints
139110$STD yq -i " .blueprints_dir = \" /opt/authentik/blueprints\" " /etc/authentik/config.yml
140- ln -s /usr/bin/python3 /usr/bin/python
141- ln -s /usr/local/bin/gunicorn /usr/bin/gunicorn
142- ln -s /usr/local/bin/celery /usr/bin/celery
143- $STD bash /opt/authentik/lifecycle/ak migrate
144- cd ~
111+ # ln -s /usr/bin/python3 /usr/bin/python
112+ # ln -s /usr/local/bin/gunicorn /usr/bin/gunicorn
113+ # ln -s /usr/local/bin/celery /usr/bin/celery
114+ # $STD bash /opt/authentik/lifecycle/ak migrate
115+ cd /opt/authentik
116+ uv run python -m lifecycle.migrate
117+ ln -s /opt/authentik/.venv/bin/gunicorn /usr/local/bin/gunicorn
118+ ln -s /opt/authentik/.venv/bin/celery /usr/local/bin/celery
119+ echo " ${RELEASE} " > /opt/${APPLICATION} _version.txt
145120msg_ok " Installed authentik"
146121
147122msg_info " Creating Services"
148123cat << EOF >/etc/systemd/system/authentik-server.service
149124[Unit]
150- Description = authentik Server
125+ Description=authentik Go Server (API Gateway)
126+ After=network.target
127+ Wants=redis.service postgresql.service
151128
152129[Service]
153- ExecStart=/opt/authentik/authentik-server
154130WorkingDirectory=/opt/authentik/
131+ ExecStart=/opt/authentik/authentik-server
155132Restart=always
156133RestartSec=5
134+ Environment=DJANGO_SETTINGS_MODULE=authentik.root.settings
157135
158136[Install]
159137WantedBy=multi-user.target
160138EOF
161139
162140cat << EOF >/etc/systemd/system/authentik-worker.service
163141[Unit]
164- Description = authentik Worker
142+ Description=authentik Celery Worker
143+ After=network.target redis.service postgresql.service
144+ Requires=redis.service
165145
166146[Service]
167- Environment=DJANGO_SETTINGS_MODULE="authentik.root.settings"
168- ExecStart=celery -A authentik.root.celery worker -Ofair --max-tasks-per-child=1 --autoscale 3,1 -E -B -s /tmp/celerybeat-schedule -Q authentik,authentik_scheduled,authentik_events
169- WorkingDirectory=/opt/authentik/authentik
147+ Type=simple
148+ WorkingDirectory=/opt/authentik
149+ ExecStart=/opt/authentik/.venv/bin/celery \
150+ -A authentik.root.celery worker \
151+ -Ofair \
152+ --max-tasks-per-child=1 \
153+ --autoscale 3,1 \
154+ -Q authentik,authentik_scheduled,authentik_events \
155+ -E
170156Restart=always
171157RestartSec=5
158+ Environment=DJANGO_SETTINGS_MODULE=authentik.root.settings
172159
173160[Install]
174161WantedBy=multi-user.target
175162EOF
176- systemctl enable -q --now authentik-server
177- sleep 2
178- systemctl enable -q --now authentik-worker
163+
164+ cat << EOF >/etc/systemd/system/authentik-celery-beat.service
165+ [Unit]
166+ Description=authentik Celery Beat Scheduler
167+ After=network.target
168+
169+ [Service]
170+ Type=simple
171+ WorkingDirectory=/opt/authentik
172+ ExecStart=/opt/authentik/.venv/bin/celery \
173+ -A authentik.root.celery beat \
174+ -s /tmp/celerybeat-schedule
175+ Restart=always
176+ RestartSec=5
177+ #User=authentik
178+ Environment=DJANGO_SETTINGS_MODULE=authentik.root.settings
179+
180+ [Install]
181+ WantedBy=multi-user.target
182+ EOF
183+
184+ systemctl enable -q --now authentik-server authentik-worker authentik-celery-beat
179185msg_ok " Created Services"
180186
181187motd_ssh
0 commit comments