summaryrefslogtreecommitdiff
path: root/opendc-web
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-06 16:16:10 +0200
committerGitHub <noreply@github.com>2021-05-06 16:16:10 +0200
commit375f329d6b276f802aafc14ce90520e807398d6e (patch)
tree69f1a0edf7223e42e143e2d1d094c6eaaad0c400 /opendc-web
parente1d892bcbaa7e8361c150f684ca6a0dc5e036a87 (diff)
parentd4eb8ccd4f5d93d9e858b9c3ed6ff48763e68820 (diff)
chore: Prepare for OpenDC 2.0 release (v2)
This pull request performs several preparations for the official release of OpenDC 2.0. With this pull request, we focus on the deployment of OpenDC to DockerHub and Maven Central. * Add workflow for creating releases on Github and publishing to Maven Central * Add workflow for publishing images on DockerHub * Add support for runtime variables in frontend Docker image * Add support for building Dokka documentation
Diffstat (limited to 'opendc-web')
-rw-r--r--opendc-web/opendc-web-api/.dockerignore8
-rw-r--r--opendc-web/opendc-web-api/.gitlab-ci.yml26
-rw-r--r--opendc-web/opendc-web-runner/build.gradle.kts16
-rw-r--r--opendc-web/opendc-web-ui/.dockerignore7
-rw-r--r--opendc-web/opendc-web-ui/.travis.yml9
-rw-r--r--opendc-web/opendc-web-ui/Dockerfile17
-rw-r--r--opendc-web/opendc-web-ui/public/index.html9
-rwxr-xr-xopendc-web/opendc-web-ui/scripts/envsubst-html.sh19
-rw-r--r--opendc-web/opendc-web-ui/src/api/routes/token-signin.js2
-rw-r--r--opendc-web/opendc-web-ui/src/api/socket.js2
-rw-r--r--opendc-web/opendc-web-ui/src/containers/auth/Login.js6
-rw-r--r--opendc-web/opendc-web-ui/src/index.js5
12 files changed, 63 insertions, 63 deletions
diff --git a/opendc-web/opendc-web-api/.dockerignore b/opendc-web/opendc-web-api/.dockerignore
new file mode 100644
index 00000000..06d67de9
--- /dev/null
+++ b/opendc-web/opendc-web-api/.dockerignore
@@ -0,0 +1,8 @@
+Dockerfile
+
+.idea/
+**/out
+*.iml
+.idea_modules/
+
+.pytest_cache
diff --git a/opendc-web/opendc-web-api/.gitlab-ci.yml b/opendc-web/opendc-web-api/.gitlab-ci.yml
deleted file mode 100644
index d80ba836..00000000
--- a/opendc-web/opendc-web-api/.gitlab-ci.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-image: "python:3.8"
-
-variables:
- PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
-
-cache:
- paths:
- - .cache/pip
-
-stages:
- - static-analysis
- - test
-
-static-analysis:
- stage: static-analysis
- script:
- - python --version
- - pip install -r requirements.txt
- - pylint opendc
-
-test:
- stage: test
- script:
- - python --version
- - pip install -r requirements.txt
- - pytest opendc
diff --git a/opendc-web/opendc-web-runner/build.gradle.kts b/opendc-web/opendc-web-runner/build.gradle.kts
index fcc78a83..60a24b92 100644
--- a/opendc-web/opendc-web-runner/build.gradle.kts
+++ b/opendc-web/opendc-web-runner/build.gradle.kts
@@ -24,7 +24,7 @@ description = "Experiment runner for OpenDC"
/* Build configuration */
plugins {
- `kotlin-library-conventions`
+ `kotlin-conventions`
application
}
@@ -33,12 +33,12 @@ application {
}
dependencies {
- api(platform(project(":opendc-platform")))
- implementation(project(":opendc-compute:opendc-compute-simulator"))
- implementation(project(":opendc-format"))
- implementation(project(":opendc-experiments:opendc-experiments-capelin"))
- implementation(project(":opendc-simulator:opendc-simulator-core"))
- implementation(project(":opendc-simulator:opendc-simulator-compute"))
+ api(platform(projects.opendcPlatform))
+ implementation(projects.opendcCompute.opendcComputeSimulator)
+ implementation(projects.opendcFormat)
+ implementation(projects.opendcExperiments.opendcExperimentsCapelin)
+ implementation(projects.opendcSimulator.opendcSimulatorCore)
+ implementation(projects.opendcTelemetry.opendcTelemetrySdk)
implementation("io.github.microutils:kotlin-logging")
implementation("com.github.ajalt.clikt:clikt:${versions["clikt"]}")
@@ -48,6 +48,4 @@ dependencies {
runtimeOnly("org.apache.logging.log4j:log4j-slf4j-impl:${versions.log4j}")
runtimeOnly("org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}")
-
- implementation(project(":opendc-telemetry:opendc-telemetry-sdk"))
}
diff --git a/opendc-web/opendc-web-ui/.dockerignore b/opendc-web/opendc-web-ui/.dockerignore
index dd87e2d7..b91894f6 100644
--- a/opendc-web/opendc-web-ui/.dockerignore
+++ b/opendc-web/opendc-web-ui/.dockerignore
@@ -1,2 +1,9 @@
+Dockerfile
+
+.idea/
+**/out
+*.iml
+.idea_modules/
+
node_modules
build
diff --git a/opendc-web/opendc-web-ui/.travis.yml b/opendc-web/opendc-web-ui/.travis.yml
deleted file mode 100644
index c3554fe4..00000000
--- a/opendc-web/opendc-web-ui/.travis.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-language: node_js
-node_js:
- - 10
-cache:
- directories:
- - node_modules
-script:
- - npm run build
- - npm test
diff --git a/opendc-web/opendc-web-ui/Dockerfile b/opendc-web/opendc-web-ui/Dockerfile
index 20e16b08..7aa3a7bf 100644
--- a/opendc-web/opendc-web-ui/Dockerfile
+++ b/opendc-web/opendc-web-ui/Dockerfile
@@ -1,4 +1,4 @@
-FROM node:14 AS staging
+FROM node:15 AS staging
MAINTAINER OpenDC Maintainers <opendc@atlarge-research.com>
# Copy package details
@@ -6,21 +6,16 @@ COPY ./package.json ./yarn.lock /opendc/
RUN cd /opendc && yarn
# Build frontend
-FROM node:14 AS build
-
-ARG OPENDC_OAUTH_CLIENT_ID
-ARG OPENDC_API_BASE_URL
-ARG OPENDC_FRONTEND_SENTRY_DSN
+FROM node:15 AS build
COPY ./ /opendc
COPY --from=staging /opendc/node_modules /opendc/node_modules
RUN cd /opendc/ \
- && export REACT_APP_OAUTH_CLIENT_ID=$OPENDC_OAUTH_CLIENT_ID \
- && export REACT_APP_API_BASE_URL=$OPENDC_API_BASE_URL \
- && export REACT_APP_SENTRY_DSN=$OPENDC_FRONTEND_SENTRY_DSN \
- && yarn build
+ && yarn build \
+ && mv build/index.html build/index.html.template
# Setup nginx to serve the frontend
-FROM nginx:1.19
+FROM nginx:1.20
+COPY --from=build /opendc/scripts/envsubst-html.sh /docker-entrypoint.d/00-envsubst-html.sh
COPY --from=build /opendc/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
diff --git a/opendc-web/opendc-web-ui/public/index.html b/opendc-web/opendc-web-ui/public/index.html
index 44a0d80f..da734797 100644
--- a/opendc-web/opendc-web-ui/public/index.html
+++ b/opendc-web/opendc-web-ui/public/index.html
@@ -33,7 +33,7 @@
<meta property="og:locale" content="en_US">
<!-- Google meta tags -->
- <meta name="google-signin-client_id" content="%REACT_APP_OAUTH_CLIENT_ID%">
+ <meta name="google-signin-client_id" content="$OAUTH_CLIENT_ID">
<meta name="google-site-verification" content="YIR4LkQTv6WmOdWv8MkeiUKni-0Yu3WHylLp4VvUMig"/>
<!-- CDN dependencies -->
@@ -52,6 +52,13 @@
gtag('js', new Date())
gtag('config', 'UA-84285092-3')
</script>
+ <script>
+ window.$$env = {
+ API_BASE_URL: "$API_BASE_URL",
+ OAUTH_CLIENT_ID: "$OAUTH_CLIENT_ID",
+ SENTRY_DSN: "$SENTRY_DSN",
+ };
+ </script>
</head>
<body>
<noscript>
diff --git a/opendc-web/opendc-web-ui/scripts/envsubst-html.sh b/opendc-web/opendc-web-ui/scripts/envsubst-html.sh
new file mode 100755
index 00000000..8ca12e8a
--- /dev/null
+++ b/opendc-web/opendc-web-ui/scripts/envsubst-html.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -e
+
+# We can use simple version of envsubst execution as
+# envsubst < /usr/share/nginx/html/index.html.template > /usr/share/nginx/html/index.html
+# but it replaces everything that looks like environment variable substitution
+# so it affects `default values` approach.
+# we need to replace only provided environment variables.
+
+auto_envsubst() {
+ template_path="/usr/share/nginx/html/index.html.template"
+ output_path="/usr/share/nginx/html/index.html"
+ defined_envs=$(printf '${%s} ' $(env | cut -d= -f1))
+ envsubst "$defined_envs" < "$template_path" > "$output_path"
+}
+
+auto_envsubst
+exit 0
diff --git a/opendc-web/opendc-web-ui/src/api/routes/token-signin.js b/opendc-web/opendc-web-ui/src/api/routes/token-signin.js
index d6cff570..e40127f2 100644
--- a/opendc-web/opendc-web-ui/src/api/routes/token-signin.js
+++ b/opendc-web/opendc-web-ui/src/api/routes/token-signin.js
@@ -1,5 +1,5 @@
export function performTokenSignIn(token) {
- const apiUrl = process.env.REACT_APP_API_BASE_URL || ''
+ const apiUrl = window.$$env['API_BASE_URL'] || ''
return fetch(`${apiUrl}/tokensignin`, {
method: 'POST',
diff --git a/opendc-web/opendc-web-ui/src/api/socket.js b/opendc-web/opendc-web-ui/src/api/socket.js
index 1c432167..884c4152 100644
--- a/opendc-web/opendc-web-ui/src/api/socket.js
+++ b/opendc-web/opendc-web-ui/src/api/socket.js
@@ -7,7 +7,7 @@ const callbacks = {}
export function setupSocketConnection(onConnect) {
const apiUrl =
- process.env.REACT_APP_API_BASE_URL ||
+ window.$$env['API_BASE_URL'] ||
`${window.location.protocol}//${window.location.hostname}:${window.location.port}`
socket = io.connect(apiUrl)
diff --git a/opendc-web/opendc-web-ui/src/containers/auth/Login.js b/opendc-web/opendc-web-ui/src/containers/auth/Login.js
index 2f9726bf..9201c09a 100644
--- a/opendc-web/opendc-web-ui/src/containers/auth/Login.js
+++ b/opendc-web/opendc-web-ui/src/containers/auth/Login.js
@@ -32,15 +32,15 @@ class LoginContainer extends React.Component {
return (
<GoogleLogin
- clientId={process.env.REACT_APP_OAUTH_CLIENT_ID}
+ clientId={window.$$env['OAUTH_CLIENT_ID']}
onSuccess={this.onAuthResponse.bind(this)}
onFailure={this.onAuthFailure.bind(this)}
render={(renderProps) => (
<span onClick={renderProps.onClick} className="login btn btn-primary">
- <span className="fa fa-google" /> Login with Google
+ <span className="fa fa-google"/> Login with Google
</span>
)}
- ></GoogleLogin>
+ />
)
}
}
diff --git a/opendc-web/opendc-web-ui/src/index.js b/opendc-web/opendc-web-ui/src/index.js
index 3517147e..bddf0b0e 100644
--- a/opendc-web/opendc-web-ui/src/index.js
+++ b/opendc-web/opendc-web-ui/src/index.js
@@ -12,10 +12,11 @@ setupSocketConnection(() => {
const store = configureStore()
// Initialize Sentry if the user has configured a DSN
- if (process.env.REACT_APP_SENTRY_DSN) {
+ const dsn = window.$$env['SENTRY_DSN']
+ if (dsn) {
Sentry.init({
environment: process.env.NODE_ENV,
- dsn: process.env.REACT_APP_SENTRY_DSN,
+ dsn: dsn,
integrations: [new Integrations.BrowserTracing()],
tracesSampleRate: 0.1,
})