Skip to content

Backend API for homepage and possibly other projects

License

Notifications You must be signed in to change notification settings

benct/tomlin-api

Repository files navigation

Tomlin.no API

Backend API for homepage (http://tomlin.no) and possible other projects.

Website GitHub last commit GitHub code size in bytes GitHub repo size in bytes GitHub licence

API, Spring, Spring Boot, REST, Kotlin, Gradle, OkHttp, Nginx, MySQL

Build and Run

./gradlew build

java -jar build/libs/tomlin-api-1.0.0.jar --spring.profiles.active=prod

JVM Options

-Dspring.profiles.active=prod

Upgrade dependencies

./gradlew dependencyUpdates

Services

Move files under service directory to /etc/systemd/system/

sudo systemctl daemon-reload
sudo systemctl enable tomlin-api && sudo systemctl start tomlin-api

Restart service on file change

sudo systemctl enable tomlin-api-watcher && sudo systemctl start tomlin-api-watcher
sudo systemctl enable tomlin-api-watcher.path && sudo systemctl start tomlin-api-watcher.path

Certbot

sudo apt install certbot python-certbot-nginx
sudo certbot --nginx
sudo certbot renew [--dry-run]

Nginx

sudo nano /etc/nginx/sites-available/default
sudo nginx -t
sudo systemctl restart nginx

Proxy configuration:

location / {
    proxy_pass http://localhost:8081/;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port $server_port;
}

Database

sudo apt install mariadb-server
mysql_secure_installation
mysql -u root -p