summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-02-17 16:52:02 +0100
committerGitHub <noreply@github.com>2022-02-17 16:52:02 +0100
commita5b32960460b2e7b52032471bf23d29832734fba (patch)
tree2ecf213097f2308b862fceb73374c6ff489faec6
parent02c215ad57e1e4d56c54d22be58e1845bdeebf25 (diff)
parent49c9f371f19e4f13c45861922b7da33da24ecf49 (diff)
merge: Update deployment via Docker
This pull request updates the deployment process to be compatible with the latest auth changes. - Support custom audience in web runner - Fix API deployment using Docker Compose - Actualize deployment guide - Update to OpenJDK 17 **External Dependencies** - Mongo 5 - OpenJDK 17
-rw-r--r--Dockerfile4
-rw-r--r--database/Dockerfile4
-rw-r--r--docker-compose.override.yml3
-rw-r--r--docker-compose.yml8
-rw-r--r--docs/deploy.md23
-rw-r--r--opendc-web/opendc-web-api/requirements.txt1
-rw-r--r--opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/Main.kt12
7 files changed, 38 insertions, 17 deletions
diff --git a/Dockerfile b/Dockerfile
index bb9a0d0d..771ed2ed 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM openjdk:16-slim
+FROM openjdk:17-slim
MAINTAINER OpenDC Maintainers <opendc@atlarge-research.com>
# Obtain (cache) Gradle wrapper
@@ -11,7 +11,7 @@ RUN ./gradlew --version
COPY ./ /app/
RUN ./gradlew --no-daemon :installDist
-FROM openjdk:16-slim
+FROM openjdk:17-slim
COPY --from=0 /app/build/install /opt/
COPY --from=0 /app/traces /opt/opendc/traces
WORKDIR /opt/opendc
diff --git a/database/Dockerfile b/database/Dockerfile
index af3a8382..e4978da6 100644
--- a/database/Dockerfile
+++ b/database/Dockerfile
@@ -1,5 +1,5 @@
-FROM mongo:4.2.8
-MAINTAINER Jacob Burley <j.burley@vu.nl>
+FROM mongo:5.0
+MAINTAINER OpenDC Maintainers <opendc@atlarge-research.com>
# Import init scripts
ADD mongo-init-opendc-db.sh /docker-entrypoint-initdb.d
diff --git a/docker-compose.override.yml b/docker-compose.override.yml
index 6202e299..5d104557 100644
--- a/docker-compose.override.yml
+++ b/docker-compose.override.yml
@@ -35,5 +35,4 @@ services:
ports:
- "8082:8081"
environment:
- ME_CONFIG_MONGODB_ADMINUSERNAME: "${MONGO_INITDB_ROOT_USERNAME}"
- ME_CONFIG_MONGODB_ADMINPASSWORD: "${MONGO_INITDB_ROOT_PASSWORD}"
+ ME_CONFIG_MONGODB_URL: "mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@mongo:27017/"
diff --git a/docker-compose.yml b/docker-compose.yml
index 18847736..52209a5b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,6 +5,8 @@ services:
restart: on-failure
networks:
- backend
+ depends_on:
+ - api
environment:
NEXT_PUBLIC_AUTH0_DOMAIN: ${OPENDC_AUTH0_DOMAIN}
NEXT_PUBLIC_AUTH0_CLIENT_ID: ${OPENDC_AUTH0_CLIENT_ID}
@@ -27,7 +29,9 @@ services:
- OPENDC_DB_PASSWORD
- OPENDC_DB_HOST=mongo
- OPENDC_FLASK_SECRET
- - OPENDC_OAUTH_CLIENT_ID
+ - AUTH0_DOMAIN=${OPENDC_AUTH0_DOMAIN}
+ - AUTH0_AUDIENCE=${OPENDC_AUTH0_AUDIENCE}
+ - AUTH0_DOCS_CLIENT_ID=${OPENDC_AUTH0_DOCS_CLIENT_ID}
- SENTRY_DSN=${OPENDC_API_SENTRY_DSN-}
- SENTRY_ENVIRONMENT
@@ -37,7 +41,7 @@ services:
networks:
- backend
depends_on:
- - mongo
+ - api
volumes:
- type: bind
source: ./traces
diff --git a/docs/deploy.md b/docs/deploy.md
index f68705cf..da622571 100644
--- a/docs/deploy.md
+++ b/docs/deploy.md
@@ -18,18 +18,25 @@ Identity Provider with good software support and a free tier for users to experi
To deploy OpenDC yourself, you need to have an [Auth0 tenant](https://auth0.com/docs/get-started/learn-the-basics) and
create:
-1. **A Single Page Application (SPA)**
+1. **An API**
+ You need to define the OpenDC API server in Auth0. Please refer to the [following guide](https://auth0.com/docs/quickstart/backend/python/01-authorization#create-an-api)
+ on how to define an API in Auth0.
+
+ Remember the identifier you created the API with, as we need it in the next steps (as `OPENDC_AUTH0_AUDIENCE`).
+2. **A Single Page Application (SPA)**
You need to define the OpenDC frontend application in Auth0. Please see the [following guide](https://auth0.com/docs/quickstart/spa/react#configure-auth0)
on how you can define an SPA in Auth0. Make sure you have added the necessary URLs to the _Allowed Callback URLs_:
for a local deployment, you should add at least `http://localhost:3000, http://localhost:8080`.
Once your application has been created, you should have a _Domain_ and _Client ID_ which we need to pass to the
frontend application (as `OPENDC_AUTH0_DOMAIN` and `OPENDC_AUTH0_CLIENT_ID` respectively).
-2. **An API**
- You need to define the OpenDC API server in Auth0. Please refer to the [following guide](https://auth0.com/docs/quickstart/backend/python/01-authorization#create-an-api)
- on how to define an API in Auth0.
-
- Remember the identifier you created the API with, as we need it in the next steps (as `OPENDC_AUTH0_AUDIENCE`).
+3. **A Machine to Machine Application (M2M)**
+ You need to define a Machine to Machine application in Auth0 so that the simulator can communicate with the OpenDC API.
+ Please refer to the [following guide](https://auth0.com/docs/get-started/auth0-overview/create-applications/machine-to-machine-apps)
+ on how to create such an application.
+
+ Once your application has been created, you should have a _Client ID_ and _Client Secret_ which we need to pass to the
+ simulator (as `OPENDC_AUTH0_CLIENT_ID_RUNNER` and `OPENDC_AUTH0_CLIENT_SECRET_RUNNER` respectively).
## Installing Docker
@@ -64,7 +71,9 @@ OPENDC_FLASK_SECRET="This is a secret flask key, please change"
OPENDC_AUTH0_DOMAIN=your-auth0-domain
OPENDC_AUTH0_CLIENT_ID=your-auth0-client-id
OPENDC_AUTH0_AUDIENCE=your-auth0-api-identifier
-OPENDC_API_BASE_URL=http://localhost:8081
+OPENDC_AUTH0_CLIENT_ID_RUNNER=your-auth0-client-id-for-runner
+OPENDC_AUTH0_CLIENT_SECRET_RUNNER=your-auth0-client-secret-for-runner
+OPENDC_API_BASE_URL=http://web
```
We provide a set of default traces for you to experiment with. If you want to add others, place them in the `traces`
diff --git a/opendc-web/opendc-web-api/requirements.txt b/opendc-web/opendc-web-api/requirements.txt
index 45eae12b..6f3b42aa 100644
--- a/opendc-web/opendc-web-api/requirements.txt
+++ b/opendc-web/opendc-web-api/requirements.txt
@@ -11,7 +11,6 @@ Flask-Cors==3.0.9
Flask-SocketIO==4.3.1
flask-swagger-ui==3.36.0
Flask-Restful==0.3.8
-greenlet==0.4.17
httplib2==0.19.0
isort==4.3.21
itsdangerous==1.1.0
diff --git a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/Main.kt b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/Main.kt
index 8f4e9d6d..94ef8f8e 100644
--- a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/Main.kt
+++ b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/Main.kt
@@ -82,6 +82,16 @@ class RunnerCli : CliktCommand(name = "runner") {
.required()
/**
+ * The auth domain to use.
+ */
+ private val authAudience by option(
+ "--auth-audience",
+ help = "auth audience of the OpenDC API",
+ envvar = "AUTH0_AUDIENCE"
+ )
+ .required()
+
+ /**
* The auth client ID to use.
*/
private val authClientId by option(
@@ -231,7 +241,7 @@ class RunnerCli : CliktCommand(name = "runner") {
override fun run(): Unit = runBlocking(Dispatchers.Default) {
logger.info { "Starting OpenDC web runner" }
- val client = ApiClient(baseUrl = apiUrl, AuthConfiguration(authDomain, authClientId, authClientSecret))
+ val client = ApiClient(baseUrl = apiUrl, AuthConfiguration(authDomain, authClientId, authClientSecret), authAudience)
val manager = ScenarioManager(client)
logger.info { "Watching for queued scenarios" }