Repository navigation
Added vt-booking host with docker compose role #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
78554a4
Added vt-booking host with docker compose role
pthormodsen 1feeaa9
Fixed ansible lint errors
pthormodsen 0d255d8
Changes env variable
pthormodsen 26184b7
Updated group vars
pthormodsen 4c485f7
final edits
pthormodsen eaa5f5c
Added community docker requirements
pthormodsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,26 @@ | ||
| $ANSIBLE_VAULT;1.1;AES256 | ||
| 35323132643564396232333034306638623934636533313039653861353465303732373131666161 | ||
| 6238303664356561663936333662666163323932653836360a333237396332636339303535646533 | ||
| 37356633353263633163646436343462626638666639346662383831616134643863363261636563 | ||
| 3866653936373538350a643666316365616235303036613066383030656166386166643661336534 | ||
| 32653662393136653133373033356130623833343831306562626662376536303237306233303638 | ||
| 30356538373964386164366430316465633464646132643931373232313666626535333666663466 | ||
| 32633537333133333838656234646537326339363633646636313234636532376133303963306638 | ||
| 32303734633462396330626363386530386465366565306233326430663164623236663061386330 | ||
| 63616562303337303933353734623535373939313363356431366264643531383761396230373338 | ||
| 38386364363063316163306365656533373034623734346432353230633837646266636231363264 | ||
| 33353937656130656335313763363762386663386236376532636265363163656337646562346632 | ||
| 32363761316134373363616464623030343137373338643532666138376139616431323436313063 | ||
| 62363137633732643830653665663333333963653532616531353064303563383334393239656465 | ||
| 31333332373265316336643762386432383432366130303135333362343030333537323865643036 | ||
| 65646639386437656365613134393936363132313639393966313162323437373236316239666631 | ||
| 35333961333435613139353235356637663235616261373165323031393264363965333435316331 | ||
| 30373238316235613937663966356438663961633336366436306235303135633362303737636338 | ||
| 3062666462303436613761613065623536356462616565366433 | ||
| 61363761383764636162396639656633356361363761373834663965303637626262383834336265 | ||
| 3834363165356137623130313562636366616433316666330a316535643536333638383038313838 | ||
| 31333133643763303530316535633934666437373834663137613337323234646265386361343763 | ||
| 6632373238346164650a386438373065656361623032646566613437323137353063343438393566 | ||
| 33646230653366343634623363366134616364373163323433613032633665613732616634363762 | ||
| 66346438323130396534623631326339616634663261363061363136306334386361353834333534 | ||
| 39336638623939323133353362323034356132623161393932386161626638313663623733353232 | ||
| 35656237666464646131376466353339363932666535633738333035353536306630323038353531 | ||
| 32313432316233653436333632326231386235643237643833326163373362306338626332393434 | ||
| 38633032623438636265636131666638663532393537663763633961633663633434393933663461 | ||
| 38333333393437373636346231306237656665393331363465353635393530396565333039366137 | ||
| 37333239663563376631333162373738343234336538646537353464303763633763626132346238 | ||
| 34326631643165393937643131323539616532663366366533386633663765303764653939396564 | ||
| 32383861346534633364656539316130373035303039373033363338643237393565616562393665 | ||
| 39363235313535306531656535623134373665386536623836666362306133343437303132653138 | ||
| 30396138343262613761636138616565346236353936396431336337306262383034623464366335 | ||
| 65643966326365353636343637613035633564666436623636613239633335633064383034393035 | ||
| 31363134393861623762646561656632653635653436363666643230383732363734653439373965 | ||
| 30623537353738643939393734303135316364376465653964623561346434653939376465663334 | ||
| 30643132663532613366393262656166323236633730613037383030393264626534313862376366 | ||
| 36303462386561316339363165396638636531333431613138613134393234666638376235333763 | ||
| 63373366353530613736663531336331376265303464343761333236626130313332333564616231 | ||
| 31333665316432386435663436373862333031373738323064316136373464653437633462663836 | ||
| 33313338343533373832353063626439363663383563666133353866653362343734376566316466 | ||
| 3632 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ srib-radio | |
| azuracast-srib | ||
| beszel | ||
| kanidm | ||
| vt-booking | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,5 +28,4 @@ | |
| - tmux | ||
| - dnsutils | ||
| - qemu-guest-agent | ||
| - podman | ||
| become: true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --- | ||
| # Domenet. Bytter dere senere, endrer du bare denne | ||
| vt_booking_domain: booking.fribyte.no | ||
|
|
||
| # Hvor app-filene ligger på serveren | ||
| vt_booking_dir: /opt/vt-booking | ||
|
|
||
| # Hvilken versjon av imagene: latest, eller en commit-SHA | ||
| vt_booking_image_tag: latest | ||
|
|
||
| # Porten appens egen nginx lytter på, bare tilgjengelig fra serveren selv | ||
| vt_booking_http_port: 8080 | ||
|
|
||
| # Fast adresseområde for Docker, så appens nettverk alltid får gateway 172.31.0.1 | ||
| vt_booking_docker_bip: 172.30.0.1/24 | ||
| vt_booking_docker_pool: 172.31.0.0/16 | ||
| vt_booking_trusted_proxy: 172.31.0.1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Common tasks for the room booking system. Run `make help` for a list. | ||
| # Requires Docker, Java 21 and Node 22 (only Docker for `make up`). | ||
|
|
||
| FRONTEND := frontend | ||
| BACKEND := backend | ||
| COMPOSE := docker compose | ||
| PROD := docker compose -f compose.prod.yaml | ||
| APP_PORT ?= 8088 | ||
| export APP_PORT | ||
|
|
||
| .PHONY: help dev test up down reset-db bootstrap-admin prod-up prod-down prod-logs prod-update prod-pull prod-bootstrap-admin | ||
|
|
||
| help: ## Show this list | ||
| @grep -E '^[a-z0-9-]+:.*## ' $(MAKEFILE_LIST) | awk -F ':.*## ' '{printf " make %-22s %s\n", $$1, $$2}' | ||
|
|
||
| $(FRONTEND)/node_modules: $(FRONTEND)/package-lock.json | ||
| cd $(FRONTEND) && npm ci | ||
| @touch $@ | ||
|
|
||
| dev: $(FRONTEND)/node_modules ## PostgreSQL in Docker, Spring Boot and React locally with hot reload | ||
| $(COMPOSE) up -d --wait db | ||
| @echo "Starting backend (:8080) and frontend (http://localhost:5173)." | ||
| @echo "Log in with your own account (first time: 'make bootstrap-admin' in another terminal). Ctrl+C stops both." | ||
| @# `exec` makes each job the real process, so the trap's kill reaches it. | ||
| @trap 'trap - INT TERM EXIT; kill $$(jobs -p) 2>/dev/null; wait' INT TERM EXIT; \ | ||
| (cd $(BACKEND) && exec ./mvnw -q spring-boot:run -Dspring-boot.run.profiles=dev) & \ | ||
| (cd $(FRONTEND) && exec npm run dev -- --strictPort) & \ | ||
| wait | ||
|
|
||
| test: $(FRONTEND)/node_modules ## Frontend and backend tests (backend needs Docker for Testcontainers) | ||
| cd $(FRONTEND) && npm test | ||
| cd $(BACKEND) && ./mvnw -q test | ||
|
|
||
| up: ## Build and run the complete application in Docker on http://localhost:8088 (APP_PORT to change) | ||
| $(COMPOSE) up -d --build --wait | ||
| @echo "Running on http://localhost:$(APP_PORT). First time: create an administrator with 'make bootstrap-admin'. Stop with 'make down'." | ||
|
|
||
| bootstrap-admin: ## Create the first system administrator (prompts for email and password; refuses if one exists) | ||
| $(COMPOSE) run --rm --build backend bootstrap-admin | ||
|
|
||
| down: ## Stop the containers (data is kept) | ||
| $(COMPOSE) down | ||
|
|
||
| reset-db: ## Delete the development database (asks first) | ||
| @printf "Delete all data in the development database? [y/N] "; read answer; \ | ||
| case "$$answer" in \ | ||
| [yY]*) $(COMPOSE) down -v && echo "Database deleted. It is recreated empty on the next 'make dev' or 'make up'; then run 'make bootstrap-admin'." ;; \ | ||
| *) echo "Cancelled." ;; \ | ||
| esac | ||
|
|
||
| # ── Production: compose.prod.yaml with settings in .env (see docs/DEPLOYMENT.md) ── | ||
|
|
||
| prod-up: ## Production: start in the background (builds the images the first time) | ||
| $(PROD) up -d --wait | ||
|
|
||
| prod-down: ## Production: stop the containers (the database is kept) | ||
| $(PROD) down | ||
|
|
||
| prod-logs: ## Production: follow the logs of all services | ||
| $(PROD) logs -f --tail=100 | ||
|
|
||
| prod-update: ## Production: rebuild the images from this checkout and restart (back up first) | ||
| $(PROD) up -d --build --wait | ||
|
|
||
| prod-pull: ## Production: pull the images built by CI (IMAGE_TAG in .env) and restart (back up first) | ||
| $(PROD) pull backend frontend | ||
| $(PROD) up -d --no-build --wait | ||
|
|
||
| prod-bootstrap-admin: ## Production: create the first system administrator (interactive) | ||
| $(PROD) run --rm backend bootstrap-admin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Production: PostgreSQL, the Spring Boot API and Nginx (the built React app), behind the host's | ||
| # HTTPS reverse proxy. Settings and secrets come from .env (copy .env.example). Use the | ||
| # `make prod-*` commands, and see docs/DEPLOYMENT.md. For development, use compose.yaml instead. | ||
| name: vt-booking-prod | ||
|
|
||
| services: | ||
| db: | ||
| image: postgres:18-alpine | ||
| environment: | ||
| POSTGRES_DB: booking | ||
| POSTGRES_USER: booking | ||
| POSTGRES_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD in .env} | ||
| volumes: | ||
| - pgdata:/var/lib/postgresql | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "pg_isready -U booking -d booking"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 10 | ||
| restart: unless-stopped | ||
| # No ports: only the API reaches the database. | ||
|
|
||
| backend: | ||
| # Pulled from GHCR (built by .github/workflows/images.yml), or built locally with `make prod-update`. | ||
| image: ghcr.io/fribyte-code/vt-booking-backend:${IMAGE_TAG:-latest} | ||
| build: backend | ||
| environment: | ||
| # No SPRING_PROFILES_ACTIVE: the dev profile must never run in production. | ||
| DB_URL: jdbc:postgresql://db:5432/booking | ||
| DB_USER: booking | ||
| DB_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD in .env} | ||
| depends_on: | ||
| db: | ||
| condition: service_healthy | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-fsS", "-o", "/dev/null", "http://localhost:8080/api/auth/csrf"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| start_period: 60s | ||
| retries: 6 | ||
| restart: unless-stopped | ||
| # No ports: only Nginx reaches the API. Never publish 8080 (see docs/DEPLOYMENT.md). | ||
|
|
||
| frontend: | ||
| image: ghcr.io/fribyte-code/vt-booking-frontend:${IMAGE_TAG:-latest} | ||
| build: frontend | ||
| environment: | ||
| # The reverse proxy in front of Nginx, as Nginx sees it, and the header with the client address. | ||
| TRUSTED_PROXY: ${TRUSTED_PROXY:-127.0.0.1} | ||
| REAL_IP_HEADER: ${REAL_IP_HEADER:-X-Forwarded-For} | ||
| volumes: | ||
| - ./frontend/real-ip.conf.template:/etc/nginx/templates/real-ip.conf.template:ro | ||
| ports: | ||
| - "${HTTP_BIND:-127.0.0.1}:${HTTP_PORT:-8080}:80" | ||
| depends_on: | ||
| backend: | ||
| condition: service_healthy | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-fsS", "-o", "/dev/null", "http://localhost/"] | ||
| interval: 10s | ||
| timeout: 5s | ||
| retries: 6 | ||
| restart: unless-stopped | ||
|
|
||
| volumes: | ||
| pgdata: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Mounted by compose.prod.yaml. At start, the Nginx image fills in the variables (from .env) and | ||
| # writes the result to /etc/nginx/conf.d/real-ip.conf. Requests from TRUSTED_PROXY, the reverse | ||
| # proxy in front of Nginx, carry the client address in REAL_IP_HEADER; from anywhere else the | ||
| # header is ignored. The default, 127.0.0.1, trusts no proxy. | ||
| set_real_ip_from ${TRUSTED_PROXY}; | ||
| real_ip_header ${REAL_IP_HEADER}; | ||
| real_ip_recursive on; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --- | ||
| - name: Restart docker | ||
| ansible.builtin.systemd_service: | ||
| name: docker | ||
| state: restarted | ||
| become: true | ||
|
|
||
| # Same as `make prod-pull` in the app repository | ||
| - name: Pull vt-booking images | ||
| ansible.builtin.command: | ||
| cmd: docker compose -f compose.prod.yaml pull backend frontend | ||
| chdir: "{{ vt_booking_dir }}" | ||
| changed_when: true | ||
| listen: Deploy vt-booking | ||
| become: true | ||
|
|
||
| - name: Start vt-booking | ||
| ansible.builtin.command: | ||
| cmd: docker compose -f compose.prod.yaml up -d --no-build --wait | ||
| chdir: "{{ vt_booking_dir }}" | ||
| changed_when: true | ||
| listen: Deploy vt-booking | ||
| become: true | ||
|
|
||
| - name: Restart nginx | ||
| ansible.builtin.systemd_service: | ||
| name: nginx | ||
| state: restarted | ||
| become: true |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.