Skip to content

Commit 1b36a37

Browse files
authored
Merge pull request #1 from h3nrique/master
Update JDK and others improvements
2 parents dfe852e + fce57ba commit 1b36a37

File tree

28 files changed

+839
-237
lines changed

28 files changed

+839
-237
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v4
17+
with:
18+
java-version: '17'
19+
distribution: 'temurin'
20+
cache: 'maven'
21+
22+
- name: Run tests
23+
run: mvn compile test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
/.idea/
22
/target
33
/dependency-reduced-pom.xml
4+
*.iml
5+
/.vscode/
6+
.classpath

Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
FROM maven:3-openjdk-17 as build
2-
LABEL authors="Paulo Henrique Alves <paulo.alves@fabricads.com.br>"
1+
FROM docker.io/library/maven:3-openjdk-17 as build
2+
LABEL authors="Paulo Henrique Alves <paulohenriqueas13@gmail.com>"
33
RUN mkdir -p /usr/src
44
WORKDIR /usr/src
55
COPY . /usr/src
66
RUN mvn clean install -DskipTests -Dmaven.javadoc.skip=true
77

8-
FROM openjdk:18
9-
LABEL authors="Paulo Henrique Alves <paulo.alves@fabricads.com.br>"
8+
FROM docker.io/library/openjdk:17
9+
LABEL authors="Paulo Henrique Alves <paulohenriqueas13@gmail.com>"
1010
EXPOSE 8091 8080
1111
COPY --from=build /usr/src/target/postalcode-spawn-demo-shaded.jar /opt/
1212
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/opt/postalcode-spawn-demo-shaded.jar"]
13-

README.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
# Postalcode Spawn Dema
1+
# Postalcode Spawn Demo
22

33
Java demo project using [Spawn](https://github.com/eigr/spawn) to find postal codes at [ViaCEP](https://viacep.com.br).
44

5-
## Locally start `Spawn Proxy` and some dependencies
5+
## Start environment
66

77
```bash
8-
docker network create spawn-demo
9-
docker-compose up mariadb nats spawn
10-
```
11-
12-
## Start Java `ActorHost` application
13-
14-
```bash
15-
docker-compose up app
8+
docker compose up
169
```
1710

1811
## Test
@@ -25,3 +18,32 @@ curl -v -H 'Content-Type: application/json' -d '{ "postalCode": "03694090" }' 'h
2518
curl -v 'http://localhost:8080/postalcode/03694090'
2619
```
2720

21+
## To deploy on Openshift with Openshift Pipeline (Tekton)
22+
23+
```bash
24+
oc create ns spawn
25+
oc process openshift//mysql-persistent -p MYSQL_USER=admin -p MYSQL_PASSWORD=admin -p MYSQL_ROOT_PASSWORD=mypassword -p MYSQL_DATABASE=eigr | oc create -n spawn -f -
26+
oc create secret generic mysql-connection-secret -n eigr-functions --from-literal=database=eigr --from-literal=host='mysql.spawn.svc.cluster.local' --from-literal=port='3306' --from-literal=username='admin' --from-literal=password='admin' --from-literal=encryptionKey=$(openssl rand -base64 32)
27+
tee actorsystem.yaml << END
28+
apiVersion: spawn-eigr.io/v1
29+
kind: ActorSystem
30+
metadata:
31+
name: spawn-demo
32+
labels:
33+
app: spawn-demo
34+
spec:
35+
# selector:
36+
# app: spawn-demo
37+
statestore:
38+
type: MySql
39+
credentialsSecretRef: mysql-connection-secret
40+
pool:
41+
size: "10"
42+
END
43+
oc create -f actorsystem.yaml -n spawn
44+
oc create -f openshift-pipeline.yaml -n spawn
45+
oc create role actorhost-pipeline --verb='*' --resource='actorhosts,actorsystems' -n spawn
46+
oc create rolebinding actorhost-pipeline --role=actorhost-pipeline --serviceaccount=spawn:pipeline -n spawn
47+
# If you want to expose actor service with route command
48+
oc create route edge postalcode --service=postalcode-spawn-demo --port=8080
49+
```

docker-compose.yaml

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.8"
2-
31
services:
42
mariadb:
53
image: mariadb
@@ -16,15 +14,11 @@ services:
1614
MYSQL_PASSWORD: admin
1715
volumes:
1816
- mariadb:/var/lib/mysql
19-
networks:
20-
- spawn-demo
2117
ports:
2218
- "3307:3306"
2319

2420
nats:
2521
image: nats:2
26-
networks:
27-
- spawn-demo
2822
ports:
2923
- "8222:8222"
3024
- "4222:4222"
@@ -34,30 +28,28 @@ services:
3428
# context: https://github.com/eigr/spawn.git#main
3529
# dockerfile: ./Dockerfile-proxy
3630
# image: spawn/proxy:main-localbuild
37-
image: eigr/spawn-proxy:1.0.0-rc.19
31+
image: eigr/spawn-proxy:1.4.1-rc.1
3832
environment:
3933
SPAWN_USE_INTERNAL_NATS: "false"
4034
SPAWN_PUBSUB_ADAPTER: nats
4135
SPAWN_PUBSUB_NATS_HOSTS: nats://nats:4222
4236
SPAWN_STATESTORE_KEY: 3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE=
43-
PROXY_APP_NAME: spawn
37+
PROXY_ACTOR_SYSTEM_NAME: spawn-system
4438
PROXY_CLUSTER_STRATEGY: gossip
4539
PROXY_DATABASE_PORT: 3306
4640
PROXY_DATABASE_TYPE: mariadb
4741
PROXY_DATABASE_HOST: mariadb
48-
PROXY_HTTP_PORT: 9003
42+
PROXY_HTTP_PORT: 9001
4943
USER_FUNCTION_PORT: 8091
5044
USER_FUNCTION_HOST: "app"
5145
# USER_FUNCTION_HOST: "host.docker.internal" # Used when run app in localhost instead container.
52-
extra_hosts:
53-
- "host.docker.internal:host-gateway"
46+
# extra_hosts:
47+
# - "host.docker.internal:host-gateway" # Used when run app in localhost instead container.
5448
depends_on:
5549
mariadb:
5650
condition: service_healthy
57-
networks:
58-
- spawn-demo
5951
ports:
60-
- "9003:9003"
52+
- "9001:9001"
6153

6254
app:
6355
build:
@@ -66,22 +58,16 @@ services:
6658
environment:
6759
ACTOR_PORT: 8091
6860
ACTOR_HOST: "app"
69-
PROXY_PORT: 9003
70-
PROXY_HOST: "spawn"
61+
SPAWN_PROXY_PORT: 9001
62+
SPAWN_PROXY_HOST: "spawn"
7163
SPAWN_SYSTEM_NAME: "spawn-system"
7264
depends_on:
7365
mariadb:
7466
condition: service_healthy
7567
# spawn-proxy:
7668
# condition: service_healthy
77-
networks:
78-
- spawn-demo
7969
ports:
8070
- "8080:8080"
8171

82-
networks:
83-
spawn-demo:
84-
external: true
85-
8672
volumes:
8773
mariadb:

k8s/actorhost.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: spawn-eigr.io/v1
2+
kind: ActorHost
3+
metadata:
4+
labels:
5+
app: postalcode-spawn-demo
6+
name: postalcode-spawn-demo
7+
annotations:
8+
spawn-eigr.io/actor-system: spawn-demo
9+
spawn-eigr.io/app-port: "8091"
10+
spawn-eigr.io/sidecar-pubsub-nats-hosts: "nats://nats.spawn.svc.cluster.local:4222"
11+
spec:
12+
# selector:
13+
# app: postalcode-spawn-demo
14+
host:
15+
image: image-registry.openshift-image-registry.svc:5000/spawn/postalcode-spawn-demo
16+
env:
17+
- name: TZ
18+
value: 'America/Sao_Paulo'
19+
- name: STARTUP_DELAY_SECONDS
20+
value: "30"
21+
- name: SPAWN_SYSTEM_NAME
22+
value: spawn-demo
23+
ports:
24+
- name: "http"
25+
containerPort: 8080
26+
- name: "actor"
27+
containerPort: 8091

k8s/deployment.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: nats
5+
labels:
6+
app: nats
7+
spec:
8+
replicas: 1
9+
strategy:
10+
type: RollingUpdate
11+
revisionHistoryLimit: 5
12+
progressDeadlineSeconds: 600
13+
selector:
14+
matchLabels:
15+
app: nats
16+
template:
17+
metadata:
18+
labels:
19+
app: nats
20+
spec:
21+
containers:
22+
- name: nats
23+
imagePullPolicy: Always
24+
image: docker.io/library/nats:2
25+
env:
26+
- name: TZ
27+
value: 'America/Sao_Paulo'
28+
ports:
29+
- name: "tcp-4222"
30+
containerPort: 4222
31+
protocol: TCP
32+
- name: "tcp-6222"
33+
containerPort: 6222
34+
protocol: TCP
35+
- name: "tcp-8222"
36+
containerPort: 8222
37+
protocol: TCP
38+
resources:
39+
requests:
40+
cpu: 100m
41+
memory: 80Mi

k8s/service.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: nats
5+
labels:
6+
app: nats
7+
spec:
8+
ports:
9+
- name: "tcp-4222"
10+
protocol: TCP
11+
port: 4222
12+
targetPort: "tcp-4222"
13+
- name: "tcp-8222"
14+
protocol: TCP
15+
port: 8222
16+
targetPort: "tcp-8222"
17+
- name: "tcp-6222"
18+
protocol: TCP
19+
port: 6222
20+
targetPort: "tcp-6222"
21+
selector:
22+
app: nats

0 commit comments

Comments
 (0)