-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish docker images to DockerHub (#958)
- Adds feature to publish the docker images of react website and libms to docker hub as well. Correctly sets the README for docker images on Docker Hub. - Refactors Github actions to improve the readability
- Loading branch information
1 parent
ea7ef18
commit caa92c2
Showing
6 changed files
with
546 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Reusable workflow for building and pushing a Docker Image to DockerHub. | ||
# | ||
# Username is taken from the repository secret, "DOCKERHUB_USERNAME" | ||
# Password is taken from the repository secret, "DOCKERHUB_TOKEN" | ||
|
||
name: Build and Push Docker Image (DockerHub) | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image-name: | ||
required: true | ||
type: string | ||
version: | ||
required: true | ||
type: string | ||
default: "latest" | ||
dockerfile: | ||
required: true | ||
type: string | ||
readme-file: | ||
required: true | ||
type: string | ||
secrets: | ||
DOCKERHUB_USERNAME: | ||
required: true | ||
DOCKERHUB_TOKEN: | ||
required: true | ||
|
||
env: | ||
registry: docker.io | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.registry }} | ||
username: ${{ env.username }} | ||
password: ${{ env.password }} | ||
|
||
- name: Check if version exists | ||
id: check_version | ||
run: | | ||
if docker manifest inspect ${{ env.registry }}/${{ env.username }}/${{ inputs.image-name }}:${{ inputs.version }} > /dev/null 2>&1; then | ||
echo "Version ${{ inputs.version }} already exists." | ||
echo "exists=true" >> $GITHUB_ENV | ||
else | ||
echo "Version ${{ inputs.version }} does not exist." | ||
echo "exists=false" >> $GITHUB_ENV | ||
fi | ||
- name: Build and push Docker image | ||
if: env.exists == 'false' | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ./docker/${{ inputs.dockerfile }} | ||
push: true | ||
tags: ${{ env.registry }}/${{ env.username }}/${{ inputs.image-name }}:${{ inputs.version }}, ${{ env.registry }}/${{ env.username }}/${{ inputs.image-name }}:latest | ||
|
||
- name: Docker Hub Description | ||
uses: peter-evans/dockerhub-description@v4 | ||
with: | ||
username: ${{ env.username }} | ||
password: ${{ env.password }} | ||
repository: ${{ env.username }}/${{ inputs.image-name }} | ||
readme-filepath: ${{ inputs.readme-file }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Introduction | ||
|
||
This is a container image for client application of | ||
the Digital Twin as a Service (DTaaS) software. | ||
This image can be used for providing a React single page web | ||
application for the DTaaS. | ||
|
||
## Authorization | ||
|
||
The react client website uses OAuth authorization. | ||
The [authorization page](https://into-cps-association.github.io/DTaaS/development/admin/client/auth.html) | ||
provides details on setting up OAuth authorization for | ||
the client application. | ||
|
||
## Use in Docker Environment | ||
|
||
### Create Docker Compose File | ||
|
||
Create an empty file named `compose.client.yml` and copy | ||
the following into the file: | ||
|
||
```yml | ||
services: | ||
client: | ||
image: intocps/dtaas-web:latest | ||
restart: unless-stopped | ||
volumes: | ||
- ./config.js:/dtaas/client/build/env.js | ||
ports: | ||
- "4000:4000" | ||
``` | ||
### Create Configuration | ||
The client application requires configuration. | ||
See the [config page](https://into-cps-association.github.io/DTaaS/development/admin/client/config.html) | ||
for an explanation of client configuration. | ||
The docker version of client application uses configuration | ||
saved in `config.js` file. Please create this file | ||
in the same file system location as that of the `compose.client.yml` file. | ||
|
||
Create a file `config.js` with the following contents: | ||
|
||
```js | ||
if (typeof window !== 'undefined') { | ||
window.env = { | ||
REACT_APP_ENVIRONMENT: 'test', | ||
REACT_APP_URL: 'http://localhost:4000/', | ||
REACT_APP_URL_BASENAME: '', | ||
REACT_APP_URL_DTLINK: '/lab', | ||
REACT_APP_URL_LIBLINK: '', | ||
REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword', | ||
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/', | ||
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab', | ||
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '', | ||
REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c', | ||
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.com/', | ||
REACT_APP_REDIRECT_URI: 'http://localhost:4000/Library', | ||
REACT_APP_LOGOUT_REDIRECT_URI: 'http://localhost:4000/', | ||
REACT_APP_GITLAB_SCOPES: 'openid profile read_user read_repository api', | ||
}; | ||
}; | ||
``` | ||
|
||
This default configuration | ||
works well if you have an account on <https://gitlab.com>. | ||
If you would like to adjust the configuration, please change this file. | ||
|
||
### Run | ||
|
||
Use the following commands to start and stop the container respectively: | ||
|
||
```bash | ||
docker compose -f compose.client.yml up -d | ||
docker compose -f compose.client.yml down | ||
``` | ||
|
||
The website will become available at <http://localhost:4000>. | ||
|
||
## Missing Workspace | ||
|
||
The docker compose only brings up the client application. | ||
This development environment does not have user workspaces and | ||
traefik gateway running in the background. As a consequence, | ||
you will see the following error. | ||
|
||
```txt | ||
Unexpected Application Error! | ||
404 Not Found | ||
``` | ||
|
||
This error can be seen on the **Library** and **Digital Twins** pages. | ||
The error is expected. | ||
|
||
If you would like to try the complete DTaaS application, please see | ||
localhost installation in | ||
[docs](https://into-cps-association.github.io/DTaaS/development/admin/localhost.html). |
Oops, something went wrong.