Java Spring Boot backend for the floaty project incl. a MySQL database.
Productive:
docker compose up
Dev (for example includes smtp4dev for email testing):
docker compose --profile dev up
Simply run the floaty Application in your IDE.
Run the services clicking arrows in docker-compose.yml file.
How to connect to MySQL database which runs in the db container from within IDEA?
- Note that 3306 is exposed s.t. it is accessible on localhost
- Go to Database tab on upper right
- Add connection
- Settings -> Host: localhost, Port: 3306 (default), User & Password as configured, Database: floaty-db
- On the Raspberry PI there is a systemd service under
/etc/systemd/system/floaty-backend.servicewhich looks like:which means that as soon as the Raspberry PI is booted, the floaty-backend service will be started. It is based on running docker compose from the floaty-backend directory.[Unit] Description=Floaty Backend Service using Docker Compose After=docker.service Requires=docker.service [Service] WorkingDirectory=/home/floaty/floaty/floaty-backend Restart=always ExecStart=/usr/bin/docker compose up ExecStop=/usr/bin/docker compose down [Install] WantedBy=multi-user.target
- CORS is allowed to be accessed from the frontend by the cors.allowed.origins property in the application.properties file. This allows traffic from https://app.floatyfly.com/.
- On the Raspberry PI runs a cloudflared (Cloudflare deamon) which tunnels traffic into the machine.
- The service is called
cloudflared.serviceand is located in/etc/systemd/system/cloudflared.service. - The service's config file is located under
/etc/cloudflared/config.ymland points to the credentials file / cloudflared config location on the machine.
- The service is called
- The domain floatyfly.com is bought via GoDaddy. The nameservers are set to the ones of Cloudflare.
- On Cloudflare a domain for floatyfly is registered, where:
- CNAME on "app" is set to the frontend hosting domain on firebase such at app.floatyfly.com resolves to the frontend.
- CNAME on "test" is set to the test floaty backend on the Raspberry PI such that test.floatyfly.com resolves to the backend.
- CNAME on "prod" is set to the prod floaty backend on the Raspberry PI such that prod.floatyfly.com resolves to the backend.
- CNAME & MX & TXT: For mailserver and spam protection check the Godaddy Settings under "My Products" -> "FloatyFly" -> "Email" -> "Deine EMail verwalten" (three dots) -> "Email Ziel einrichten" to see all necessary DNS records for EMail.
- For local development, H2 or MySQL can be used. The MySQL database is being run in a docker container (can be started via docker compose).
- For production, also MySQL is used similarly.