Skip to content

Commit 78ec04e

Browse files
committed
Renaming to java-swing-tutor
1 parent ab3c56d commit 78ec04e

252 files changed

Lines changed: 1398 additions & 663 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-desktop.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
jpackage --input target \
5959
--name "Java Swing Tutor" \
6060
--main-jar $JAR_NAME \
61-
--main-class com.posadskiy.javaswingteacher.Start \
61+
--main-class com.posadskiy.javaswingtutor.Start \
6262
--type dmg \
6363
--dest target/jpackage \
6464
--app-version $APP_VERSION \
@@ -70,7 +70,7 @@ jobs:
7070
jpackage --input target \
7171
--name "Java Swing Tutor" \
7272
--main-jar $JAR_NAME \
73-
--main-class com.posadskiy.javaswingteacher.Start \
73+
--main-class com.posadskiy.javaswingtutor.Start \
7474
--type app-image \
7575
--dest target/jpackage \
7676
--app-version $APP_VERSION \
@@ -123,7 +123,7 @@ jobs:
123123
jpackage --input target \
124124
--name "Java Swing Tutor" \
125125
--main-jar $JAR_NAME \
126-
--main-class com.posadskiy.javaswingteacher.Start \
126+
--main-class com.posadskiy.javaswingtutor.Start \
127127
--type dmg \
128128
--dest target/jpackage \
129129
--app-version $APP_VERSION \
@@ -135,7 +135,7 @@ jobs:
135135
jpackage --input target \
136136
--name "Java Swing Tutor" \
137137
--main-jar $JAR_NAME \
138-
--main-class com.posadskiy.javaswingteacher.Start \
138+
--main-class com.posadskiy.javaswingtutor.Start \
139139
--type app-image \
140140
--dest target/jpackage \
141141
--app-version $APP_VERSION \
@@ -190,7 +190,7 @@ jobs:
190190
jpackage --input target `
191191
--name "JSTutor" `
192192
--main-jar $JAR_NAME `
193-
--main-class com.posadskiy.javaswingteacher.Start `
193+
--main-class com.posadskiy.javaswingtutor.Start `
194194
--type exe `
195195
--dest X:\d `
196196
--temp C:\t `
@@ -205,7 +205,7 @@ jobs:
205205
jpackage --input target `
206206
--name "JSTutor" `
207207
--main-jar $JAR_NAME `
208-
--main-class com.posadskiy.javaswingteacher.Start `
208+
--main-class com.posadskiy.javaswingtutor.Start `
209209
--type app-image `
210210
--dest X:\d `
211211
--temp C:\t `
@@ -261,7 +261,7 @@ jobs:
261261
jpackage --input target \
262262
--name "Java Swing Tutor" \
263263
--main-jar $JAR_NAME \
264-
--main-class com.posadskiy.javaswingteacher.Start \
264+
--main-class com.posadskiy.javaswingtutor.Start \
265265
--type deb \
266266
--dest target/jpackage \
267267
--app-version $APP_VERSION \
@@ -274,7 +274,7 @@ jobs:
274274
jpackage --input target \
275275
--name "Java Swing Tutor" \
276276
--main-jar $JAR_NAME \
277-
--main-class com.posadskiy.javaswingteacher.Start \
277+
--main-class com.posadskiy.javaswingtutor.Start \
278278
--type app-image \
279279
--dest target/jpackage \
280280
--app-version $APP_VERSION \

.github/workflows/release-desktop.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
jpackage --input target \
4949
--name "Java Swing Tutor" \
5050
--main-jar $JAR_NAME \
51-
--main-class com.posadskiy.javaswingteacher.Start \
51+
--main-class com.posadskiy.javaswingtutor.Start \
5252
--type dmg \
5353
--dest target/jpackage \
5454
--app-version $APP_VERSION \
@@ -60,7 +60,7 @@ jobs:
6060
jpackage --input target \
6161
--name "Java Swing Tutor" \
6262
--main-jar $JAR_NAME \
63-
--main-class com.posadskiy.javaswingteacher.Start \
63+
--main-class com.posadskiy.javaswingtutor.Start \
6464
--type app-image \
6565
--dest target/jpackage \
6666
--app-version $APP_VERSION \
@@ -92,7 +92,7 @@ jobs:
9292
jpackage --input target `
9393
--name "JSTutor" `
9494
--main-jar $JAR_NAME `
95-
--main-class com.posadskiy.javaswingteacher.Start `
95+
--main-class com.posadskiy.javaswingtutor.Start `
9696
--type exe `
9797
--dest X:\d `
9898
--temp C:\t `
@@ -107,7 +107,7 @@ jobs:
107107
jpackage --input target `
108108
--name "JSTutor" `
109109
--main-jar $JAR_NAME `
110-
--main-class com.posadskiy.javaswingteacher.Start `
110+
--main-class com.posadskiy.javaswingtutor.Start `
111111
--type app-image `
112112
--dest X:\d `
113113
--temp C:\t `
@@ -137,7 +137,7 @@ jobs:
137137
jpackage --input target \
138138
--name "Java Swing Tutor" \
139139
--main-jar $JAR_NAME \
140-
--main-class com.posadskiy.javaswingteacher.Start \
140+
--main-class com.posadskiy.javaswingtutor.Start \
141141
--type deb \
142142
--dest target/jpackage \
143143
--app-version $APP_VERSION \
@@ -150,7 +150,7 @@ jobs:
150150
jpackage --input target \
151151
--name "Java Swing Tutor" \
152152
--main-jar $JAR_NAME \
153-
--main-class com.posadskiy.javaswingteacher.Start \
153+
--main-class com.posadskiy.javaswingtutor.Start \
154154
--type app-image \
155155
--dest target/jpackage \
156156
--app-version $APP_VERSION \

Answer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.posadskiy.javaswingteacher.presentation.component;
1+
package com.posadskiy.javaswingtutor.presentation.component;
22
import javax.swing.*;
33
import java.awt.*;
44

README.md

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,23 @@ The client automatically connects to the backend service at `http://localhost:80
128128

129129
#### Desktop Client
130130

131-
| Variable | Description | Default |
132-
|------------------------------|-------------------------------------------------|-------------------------|
133-
| `SWINGTEACHER_SERVICE_URL` | Backend service URL | `http://localhost:8080` |
134-
| `SWINGTEACHER_USE_REMOTE` | Use REST API for data access | `true` |
135-
| `SWINGTEACHER_USE_DB` | Fallback to direct database access | `false` |
136-
| `SWINGTEACHER_SMTP_USERNAME` | SMTP username for email verification (optional) | - |
137-
| `SWINGTEACHER_SMTP_PASSWORD` | SMTP password for email verification (optional) | - |
131+
| Variable | Description | Default |
132+
|-----------------------------------|-------------------------------------------------|-------------------------|
133+
| `JAVA_SWING_TUTOR_SERVICE_URL` | Backend service URL | `http://localhost:8080` |
134+
| `JAVA_SWING_TUTOR_USE_REMOTE` | Use REST API for data access | `true` |
135+
| `JAVA_SWING_TUTOR_USE_DB` | Fallback to direct database access | `false` |
136+
| `JAVA_SWING_TUTOR_SMTP_USERNAME` | SMTP username for email verification (optional) | - |
137+
| `JAVA_SWING_TUTOR_SMTP_PASSWORD` | SMTP password for email verification (optional) | - |
138138

139139
#### Backend Service
140140

141-
| Variable | Description | Default |
142-
|----------------------------------|-----------------------------|-------------------------------------------------|
143-
| `SWINGTEACHER_DATABASE_URL` | PostgreSQL connection URL | `jdbc:postgresql://localhost:5450/swingteacher` |
144-
| `SWINGTEACHER_DATABASE_USER` | Database username | `swingteacher` |
145-
| `SWINGTEACHER_DATABASE_PASSWORD` | Database password | `swingteacher` |
146-
| `SWINGTEACHER_SERVICE_PORT` | Service port | `8080` |
147-
| `SPRING_PROFILES_ACTIVE` | Spring profile (dev/docker) | `dev` |
141+
| Variable | Description | Default |
142+
|-------------------------------------|-----------------------------|-----------------------------------------------------------|
143+
| `JAVA_SWING_TUTOR_DB_URL` | PostgreSQL connection URL | `jdbc:postgresql://localhost:5450/java_swing_tutor` |
144+
| `JAVA_SWING_TUTOR_DB_USER` | Database username | `java_swing_tutor` |
145+
| `JAVA_SWING_TUTOR_DB_PASSWORD` | Database password | `java_swing_tutor` |
146+
| `JAVA_SWING_TUTOR_SERVICE_PORT` | Service port | `8080` |
147+
| `SPRING_PROFILES_ACTIVE` | Spring profile (dev/docker) | `dev` |
148148

149149
### Docker Compose Configuration
150150

@@ -156,9 +156,9 @@ The `docker-compose.yml` file configures:
156156

157157
Database credentials (Docker environment):
158158

159-
- **Database**: `swingteacher`
160-
- **User**: `swingteacher`
161-
- **Password**: `swingteacher`
159+
- **Database**: `java_swing_tutor`
160+
- **User**: `java_swing_tutor`
161+
- **Password**: `java_swing_tutor`
162162
- **Port**: `5450` (host) / `5432` (container)
163163

164164
## 🔧 Local Development
@@ -227,6 +227,8 @@ java-swing-tutor/
227227
│ └── src/main/resources/
228228
│ └── i18n/ # Internationalization files
229229
230+
├── deployment/ # Shared cluster config and scripts (see deployment/README.md)
231+
├── website/ # Next.js website (and website/deployment/ for deploy)
230232
├── docker-compose.yml # Docker services configuration
231233
├── Dockerfile # Service container image
232234
└── pom.xml # Root Maven POM
@@ -322,6 +324,22 @@ docker compose down
322324
docker compose logs -f service
323325
```
324326

327+
## ☸️ Kubernetes deployment
328+
329+
Shared cluster config is in **`deployment/`**; website and backend each have their own **`deployment/`** (manifests + scripts). See **[deployment/README.md](deployment/README.md)** for layout and backend prerequisites.
330+
331+
```bash
332+
# 1. Prepare cluster (namespace, config, Traefik)
333+
./deployment/scripts/k3s/deploy-to-k3s.sh
334+
335+
# 2. Build and push images
336+
./deployment/scripts/dockerhub/build-and-push-all.sh <version>
337+
338+
# 3. Deploy website and backend from their folders
339+
cd website && ./deployment/scripts/deploy.sh <version>
340+
cd ../service && ./deployment/scripts/deploy.sh <version>
341+
```
342+
325343
## 📚 Learning Path
326344

327345
The application includes 50+ lessons covering:

deployment/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Deployment
2+
3+
Shared cluster config and scripts for java-swing-tutor. **Cluster-only** setup lives here; website and backend are deployed from their own **`deployment/`** folders.
4+
5+
## What’s here (common)
6+
7+
- **namespace.yaml**, **configmap.yaml**, **secrets.yaml** – shared for namespace `java-swing-tutor`
8+
- **ingress/** – Traefik IngressRoute, Let’s Encrypt, middlewares; api-ingress.yaml (optional standard Ingress for API)
9+
- **scripts/k3s/deploy-to-k3s.sh** – prepare cluster only (namespace, registry secret, ConfigMap, Secrets, Traefik). Does **not** deploy website or backend.
10+
- **scripts/k3s/install-k3s.sh**, **setup-env.sh** – k3s install and env checks
11+
- **scripts/dockerhub/create-registry-secret.sh** – Docker Hub pull secret
12+
- **scripts/dockerhub/build-and-push-all.sh** – build and push both images (calls website and service `deployment/scripts/build-and-push.sh`)
13+
- **scripts/common/get-version.sh** – version from pom.xml or package.json
14+
15+
## What’s in each app
16+
17+
- **website/deployment/** – website-deployment.yaml, website-service.yaml, website-network-policy.yaml, website-ingress.yaml; **scripts/deploy.sh**, **scripts/build-and-push.sh**
18+
- **service/deployment/** – deployment.yaml, service.yaml, network-policy.yaml (java-swing-tutor-service); **scripts/deploy.sh**, **scripts/build-and-push.sh**
19+
20+
## Order of operations
21+
22+
1. Set env: `DOCKERHUB_USERNAME`, `DOCKERHUB_TOKEN`, `K3S_SERVER_IP`, `K3S_SSH_USER`; for backend: `JAVA_SWING_TUTOR_DB_PASSWORD` etc. (see **scripts/k3s/setup-env.sh**).
23+
2. **Prepare cluster** (from this folder):
24+
`./scripts/k3s/deploy-to-k3s.sh`
25+
3. **Build and push images**:
26+
`./scripts/dockerhub/build-and-push-all.sh <version>`
27+
4. **Deploy website**:
28+
`cd ../website && ./deployment/scripts/deploy.sh <version>`
29+
5. **Deploy backend**:
30+
`cd ../service && ./deployment/scripts/deploy.sh <version>`
31+
32+
## Backend prerequisites
33+
34+
- Postgres: ConfigMap `db.url` uses `postgres-service:5432/java_swing_tutor` (or override in configmap).
35+
- Secrets: `JAVA_SWING_TUTOR_DB_PASSWORD`, `JAVA_SWING_TUTOR_DB_USER` (see secrets.yaml).

deployment/configmap.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: java-swing-tutor-config
5+
namespace: java-swing-tutor
6+
data:
7+
db.url: "jdbc:postgresql://postgres-service:5432/java_swing_tutor"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# API Ingress (Traefik) - api.java-swing.com with TLS via Traefik's built-in ACME
2+
# Optional standard Ingress; main routing uses traefik-ingressroute.yaml in this folder
3+
# Website ingress: website/deployment/website-ingress.yaml
4+
apiVersion: networking.k8s.io/v1
5+
kind: Ingress
6+
metadata:
7+
name: java-swing-tutor-api-ingress
8+
namespace: default
9+
labels:
10+
app: java-swing-tutor-service
11+
annotations:
12+
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
13+
traefik.ingress.kubernetes.io/router.tls.certresolver: letsencrypt
14+
spec:
15+
ingressClassName: traefik
16+
tls:
17+
- hosts:
18+
- api.java-swing.com
19+
rules:
20+
- host: api.java-swing.com
21+
http:
22+
paths:
23+
- path: /
24+
pathType: Prefix
25+
backend:
26+
service:
27+
name: java-swing-tutor-service
28+
port:
29+
number: 8080
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
apiVersion: traefik.io/v1alpha1
2+
kind: IngressRoute
3+
metadata:
4+
name: java-swing-tutor
5+
namespace: java-swing-tutor
6+
spec:
7+
entryPoints:
8+
- websecure
9+
routes:
10+
# Website - java-swing.com, www.java-swing.com
11+
- match: Host(`java-swing.com`) || Host(`www.java-swing.com`)
12+
kind: Rule
13+
services:
14+
- name: java-swing-tutor-website
15+
port: 80
16+
middlewares:
17+
- name: rate-limit-middleware
18+
priority: 10
19+
20+
# API - api.java-swing.com
21+
- match: Host(`api.java-swing.com`)
22+
kind: Rule
23+
services:
24+
- name: java-swing-tutor-service
25+
port: 8080
26+
middlewares:
27+
- name: cors-middleware
28+
- name: rate-limit-middleware
29+
priority: 10
30+
31+
# Health check
32+
- match: Host(`api.java-swing.com`) && Path(`/actuator/health`)
33+
kind: Rule
34+
services:
35+
- name: java-swing-tutor-service
36+
port: 8080
37+
priority: 20
38+
39+
tls:
40+
certResolver: letsencrypt
41+
domains:
42+
- main: java-swing.com
43+
sans:
44+
- www.java-swing.com
45+
- main: api.java-swing.com
46+
47+
---
48+
# Traefik Let's Encrypt configuration
49+
apiVersion: traefik.io/v1alpha1
50+
kind: TLSOption
51+
metadata:
52+
name: tls-options
53+
namespace: java-swing-tutor
54+
spec:
55+
minVersion: VersionTLS12
56+
cipherSuites:
57+
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
58+
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
59+
- TLS_ECDHE_RSA_WITH_AES_128_SHA256
60+
- TLS_ECDHE_RSA_WITH_AES_256_SHA384

0 commit comments

Comments
 (0)