Skip to content

Commit fa1a143

Browse files
✨ πŸ”§ Configure Cloud Run deployment (#37)
* πŸ”§ Configure Cloud Run & update doc
1 parent 0c27bb3 commit fa1a143

9 files changed

Lines changed: 43 additions & 11 deletions

File tree

β€Ž.env-exampleβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# This is an example of env file.
2-
github.token=<set your token here>
1+
%dev.github.token=<your-token>
2+
quarkus.langchain4j.mcp.github.environment.GITHUB_PERSONAL_ACCESS_TOKEN=<your-token>>
3+
GITHUB_TOKEN=<your-token>>

β€Ž.gcloudignoreβ€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.git/
2+
.gitignore
3+
.env
4+
.vscode/
5+
.dockerignore
6+
*.md
7+
.agents/

β€ŽDockerfileβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ COPY target/quarkus-app/*.jar /deployments/
88
COPY target/quarkus-app/app/ /deployments/app/
99
COPY target/quarkus-app/quarkus/ /deployments/quarkus/
1010

11-
EXPOSE 8080 8888
12-
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
11+
EXPOSE 8080
12+
ENV JAVA_OPTS="-Dquarkus.http.port=8081 -Djavelit.port=8080 -Djavelit.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
1313
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
1414
ENTRYPOINT [ "/bin/sh", "-c", "java $JAVA_OPTS -jar $JAVA_APP_JAR" ]

β€ŽREADME.mdβ€Ž

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ An interface made with Javelit is available.
3939

4040
> 🎯 The last resource will be removed after implementing all features and will be replaced by schedules.
4141
42-
## πŸ“ Setup
42+
## πŸ“ Local Setup
4343

4444
- You need a GitHub token you can generate on [this page](https://github.com/settings/tokens).
4545
- Create a `.env` file based on the `.env-example` file and set the token previously created.
@@ -63,12 +63,27 @@ Then run the container mapping the ports (8080 for API, 8888 for UI) and mountin
6363

6464
```bash
6565
docker run -it --rm \
66-
-p 8080:8080 -p 8888:8888 \
66+
-p 8080:8081 \
6767
-v "$(pwd)/.gcloud-conf.json:/etc/gcp/creds.json:ro" \
68+
--env-file .env \
6869
-e GOOGLE_APPLICATION_CREDENTIALS=/etc/gcp/creds.json \
6970
zoss-dashboard
7071
```
7172

73+
## β›… Deploy on Cloud Run
74+
75+
This project can be deployed on [Cloud Run](https://cloud.google.com/run) with this command:
76+
77+
```bash
78+
gcloud run deploy zenika-opensource-statistics \
79+
--source . \
80+
--region $GOOGLE_CLOUD_LOCATION \
81+
--project $GOOGLE_CLOUD_PROJECT_ID \
82+
--allow-unauthenticated \
83+
--memory 1Gi \
84+
--max-instances 1
85+
```
86+
7287
## ✨Contribute
7388

7489
Anyone can contribute to this project. For the moment, please add your question or propose something in [a new issue](https://github.com/zenika-open-source/opensource-statistics/issues).

β€Žpom.xmlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>org.acme</groupId>
4+
<groupId>zenika.opensource</groupId>
55
<artifactId>oss-stats</artifactId>
66
<version>1.3.0</version>
77
<properties>

β€Žsrc/main/java/zenika/oss/stats/config/GitHubClient.javaβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
public interface GitHubClient {
2121

2222
default String prepareToken() {
23-
String token = ConfigProvider.getConfig().getValue("github.token", String.class);
23+
String token = ConfigProvider.getConfig().getOptionalValue("github.token", String.class).orElse("");
2424
return "Bearer " + token;
2525
}
2626

β€Žsrc/main/java/zenika/oss/stats/services/GitHubServices.javaβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.HashMap;
3030
import java.util.List;
3131
import java.util.Locale;
32+
import java.util.Optional;
3233
import java.util.concurrent.ExecutionException;
3334
import java.util.stream.Collectors;
3435

@@ -51,15 +52,15 @@ public class GitHubServices {
5152
String graphQLUrl;
5253

5354
@ConfigProperty(name = "github.token")
54-
String githubToken;
55+
Optional<String> githubToken;
5556

5657
DynamicGraphQLClient dynamicGraphQLClient;
5758

5859
@PostConstruct
5960
public void init() {
6061
dynamicGraphQLClient = DynamicGraphQLClientBuilder.newBuilder()
6162
.url(graphQLUrl)
62-
.header("Authorization", "Bearer " + githubToken)
63+
.header("Authorization", "Bearer " + githubToken.orElse(""))
6364
.build();
6465
}
6566

β€Žsrc/main/java/zenika/oss/stats/ui/JavelitDashboard.javaβ€Ž

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@
1313

1414
import java.util.List;
1515

16+
import org.eclipse.microprofile.config.inject.ConfigProperty;
17+
18+
1619
@ApplicationScoped
1720
public class JavelitDashboard {
1821

22+
@ConfigProperty(name = "javelit.port", defaultValue = "8888")
23+
int port;
24+
1925
@Inject
2026
MembersTab membersTab;
2127

@@ -43,6 +49,6 @@ void onStart(@Observes StartupEvent ev) {
4349
contributionsTab.render(tabs.tab("πŸ“Š Contributions"));
4450
statsTab.render(tabs.tab("πŸ“ˆ Stats"));
4551

46-
}, 8888).build().start();
52+
}, port).build().start();
4753
}
4854
}

β€Žsrc/main/resources/application.propertiesβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
quarkus.datasource.db-kind=postgresql
33
quarkus.datasource.jdbc.url=jdbc:postgresql:///mydatabase
4+
quarkus.http.port=8081
45
quarkus.datasource.username=quarkus
56
quarkus.datasource.password=quarkus
67
quarkus.datasource.jdbc.additional-jdbc-properties.cloudSqlInstance=project-id:gcp-region:instance
@@ -15,6 +16,7 @@ organization.name=zenika-open-source
1516

1617
# GitHub API configuration
1718
%test.github.token=test
19+
github.token=
1820

1921
quarkus.rest-client.github-api.url=https://api.github.com/
2022
quarkus.smallrye-graphql-client.github-api.url=https://api.github.com/graphql

0 commit comments

Comments
Β (0)