-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06e93cd
commit ab48a8c
Showing
9 changed files
with
185 additions
and
15 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
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,49 @@ | ||
# | ||
# This source file is part of the Stanford Biodesign Digital Health TypeScript Template open-source project | ||
# Based on the Apodini workflow found at: https://github.com/Apodini/.github/workflows/docker-compose-test.yml | ||
# | ||
# SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
name: Docker Compose | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
dockerComposeFile: | ||
description: 'Path or name of the Docker compose file. The default values is `docker-compose.yml`' | ||
required: false | ||
type: string | ||
default: 'docker-compose.yml' | ||
workingDirectory: | ||
description: 'The workingDirectory of the GitHub Action. Defaults to $GITHUB_WORKSPACE' | ||
required: false | ||
type: string | ||
default: '.' | ||
testscript: | ||
description: 'Optional path or name to a test script to test the Docker compose setup' | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
buildandtest: | ||
name: Build and Test | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
workingDirectory: ${{ inputs.workingDirectory }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Docker compose up | ||
run: docker-compose -f ${{ inputs.workingDirectory }}/${{ inputs.dockerComposeFile }} up -d --build | ||
- name: Run test script | ||
if: inputs.testscript != '' | ||
run: | | ||
sleep 5 | ||
sh ${{ inputs.testscript }} | ||
- name: Docker compose down | ||
if: always() | ||
run: docker-compose down |
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
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,54 @@ | ||
# | ||
# This source file is part of the Stanford Biodesign Digital Health TypeScript Template open-source project | ||
# Based on the Apodini workflow found at: https://github.com/Apodini/ApodiniExample/docker-compose-development.yml | ||
# | ||
# SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
version: '3.9' | ||
|
||
services: | ||
# An TypeScript Template | ||
stanford-bdhg-typescript-template: | ||
container_name: 'stanford-bdhg-typescript-template' | ||
image: 'stanfordbdgh/typescripttemplate:dev' | ||
build: | ||
context: ./ | ||
dockerfile: ./Dockerfile | ||
expose: | ||
- '80' | ||
command: ['node', 'server.js'] | ||
labels: | ||
# The domain the service will respond to | ||
- 'traefik.http.routers.backend.rule=Host(`localhost`)' | ||
# Allow request only from the predefined entry point named "web" | ||
- 'traefik.http.routers.backend.entrypoints=web' | ||
# We need to define the a service and specify, on which port our server is reachable | ||
- 'traefik.http.services.backend-service.loadbalancer.server.port=80' | ||
# We have to add this service to our router "backend". That's how the router knows where to forward the requests | ||
- 'traefik.http.routers.backend.service=backend-service' | ||
# Reverse Proxy to protect our service from direct access | ||
traefik: | ||
container_name: 'traefik' | ||
image: 'traefik:v2.4' | ||
command: | ||
# Enable Debug output | ||
- '--log.level=DEBUG' | ||
# Enable the api and the traefik dashboard for debugging purposes, which can be reached under 127.0.0.1:8080 | ||
- '--api.insecure=true' | ||
- '--api.dashboard=true' | ||
# Enabling docker provider | ||
- '--providers.docker=true' | ||
# Traefik will listen to incoming request on the port 80 | ||
- '--entrypoints.web.address=:80' | ||
ports: | ||
# 8080 on the container is mapped to 8080 on the server/VM/your Machine. | ||
# Port 8080 is where the api traefik dashboard is located | ||
- '8080:8080' | ||
# Port 80 is where our stanford-bdhg-typescript-template is running | ||
- '80:80' | ||
# Traefik needs the docker.sock to detect new docker container | ||
volumes: | ||
- '/var/run/docker.sock:/var/run/docker.sock:ro' |
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,43 @@ | ||
# | ||
# This source file is part of the Stanford Biodesign Digital Health TypeScript Template open-source project | ||
# Based on the Apodini workflow found at: https://github.com/Apodini/ApodiniExample/docker-compose.yml | ||
# | ||
# SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
version: '3.9' | ||
|
||
services: | ||
# An TypeScript Template | ||
stanford-bdhg-typescript-template: | ||
container_name: 'stanford-bdhg-typescript-template' | ||
image: 'ghcr.io/stanfordbdhg/typescripttemplate:latest' | ||
expose: | ||
- '80' | ||
command: ['node', 'server.js'] | ||
labels: | ||
# The domain the service will respond to | ||
- 'traefik.http.routers.backend.rule=Host(`localhost`)' | ||
# Allow request only from the predefined entry point named "web" | ||
- 'traefik.http.routers.backend.entrypoints=web' | ||
# We need to define the a service and specify, on which port our server is reachable | ||
- 'traefik.http.services.backend-service.loadbalancer.server.port=80' | ||
# We have to add this service to our router "backend". That's how the router knows where to forward the requests | ||
- 'traefik.http.routers.backend.service=backend-service' | ||
# Reverse Proxy to protect our service from direct access | ||
traefik: | ||
container_name: 'traefik' | ||
image: 'traefik:v2.4' | ||
command: | ||
# Enabling docker provider | ||
- '--providers.docker=true' | ||
# Traefik will listen to incoming request on the port 80 (HTTP) | ||
- '--entrypoints.web.address=:80' | ||
ports: | ||
# 80 on the container is mapped to 80 on the server/VM/your Machine. | ||
- '80:80' | ||
# Traefik needs the docker.sock to detect new docker container | ||
volumes: | ||
- '/var/run/docker.sock:/var/run/docker.sock:ro' |
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,16 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# This source file is part of the Stanford OwnYourData Application project | ||
# | ||
# SPDX-FileCopyrightText: 2023 Stanford University | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
set -e | ||
|
||
CONTENT=$(curl --fail http://localhost:3000) | ||
echo "$CONTENT" | grep "Welcome to the Stanford Biodesign Digital Health TypeScript Template" | ||
|
||
echo "✅ Test Passed!" |