Skip to content

Commit

Permalink
Merge pull request #102 from visdesignlab/72-github-actions
Browse files Browse the repository at this point in the history
72 GitHub actions
  • Loading branch information
bbollen23 authored Sep 13, 2024
2 parents b921255 + b0ef9a4 commit ec8ad17
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .build-files/Dockerfile.loon.local
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ COPY . .

# Run a command to keep the container running
# Specifying config and overwriting.
CMD ["python3", "build.py", "-o", "--config-file", ".build-files/config-local.json"]
CMD ["python3", "-u", "build.py", "-os", "--config-file", ".build-files/config-local.json"]
2 changes: 1 addition & 1 deletion .build-files/Dockerfile.loon.minio
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ COPY . .

# Run a command to keep the container running
# Specifying config and overwriting.
CMD ["python3", "build.py", "-o", "--config-file", ".build-files/config-standard.json"]
CMD ["python3", "-u", "build.py", "-os", "--config-file", ".build-files/config-standard.json"]
1 change: 1 addition & 0 deletions .build-files/docker-compose-local.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
- "80:80"
depends_on:
- server
- celery
env_file:
- path: ${DOCKER_ENV_FILE} # relative to docker compose (has to be in same directory)
required: true
Expand Down
1 change: 1 addition & 0 deletions .build-files/docker-compose.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
- ${SSL_MAPPING:-/dev/null:/dev/null}
depends_on:
- server
- celery
env_file:
- path: ${DOCKER_ENV_FILE} # relative to docker compose (has to be in same directory)
required: true
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/deploy-to-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ jobs:
working-directory: ./apps/docs-website # Change this to your Docusaurus directory
run: yarn install

# Make versioning stuff here

- name: Update baseURL
working-directory: ./apps/docs-website
run: |
sed -i 's/baseUrl: "\/"/baseUrl: "\/loonar\//g' docusaurus.config.ts
# Build the Docusaurus site
- name: Build Docusaurus
working-directory: ./apps/docs-website # Change this to your Docusaurus directory
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-website/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const config: Config = {
url: "https://your-docusaurus-site.example.com",
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: "/loonar/",
baseUrl: "/",

// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
Expand Down
53 changes: 33 additions & 20 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,26 @@ def follow_logs(service_name, logs_path, verbose=False, detached=False):
# Optionally send std error to subprocess.PIPE and then take STDERR and log to error file


def build_containers(env_file):
def build_containers(env_file, disable_spinner=False):
global stop_spinner
stop_spinner = False
""" Build the containers. """
# print("Building Containers...")
spinner_thread = threading.Thread(target=spinner, args=("Building containers...",))
spinner_thread.start()
if not disable_spinner:
stop_spinner = False
""" Build the containers. """
spinner_thread = threading.Thread(target=spinner, args=("Building containers...",))
spinner_thread.start()
else:
print("Building containers...")

process = run_command(f"docker-compose -f .build-files/docker-compose.yml"
f" --env-file {env_file} build")
process.wait() # Wait for the build to complete

stop_spinner = True
spinner_thread.join() # Ensure spinner thread completes
print("\nBuild complete.") # Print new line after spinner stops
if not disable_spinner:
stop_spinner = True
spinner_thread.join() # Ensure spinner thread completes
print("\nBuild complete.") # Print new line after spinner stops
else:
print("Build Complete.")


def follow_all_logs(logs_path, services, verbose=False, detached=False):
Expand All @@ -274,21 +280,26 @@ def follow_all_logs(logs_path, services, verbose=False, detached=False):
log_thread.start()


def start_containers(env_file):
def start_containers(env_file, disable_spinner=False):
global stop_spinner
stop_spinner = False
""" Start the containers in detached mode. """
spinner_thread = threading.Thread(target=spinner, args=("Starting containers...",))
spinner_thread.start()
if not disable_spinner:
stop_spinner = False
""" Start the containers in detached mode. """
spinner_thread = threading.Thread(target=spinner, args=("Starting containers...",))
spinner_thread.start()
else:
print("Starting containers...")
process = run_command(f"docker-compose -f .build-files/docker-compose.yml"
f" --env-file {env_file} up -d")

process.wait() # Wait for the containers to start

stop_spinner = True
spinner_thread.join() # Ensure spinner thread completes

print("\nContainers started.")
if not disable_spinner:
stop_spinner = True
spinner_thread.join() # Ensure spinner thread completes
print("\nContainers started.")
else:
print("Build Complete.")


def check_containers_status(services, detached=False):
Expand Down Expand Up @@ -362,6 +373,8 @@ def spinner(msg):
"corresponding environment file.")
parser.add_argument("-o", "--overwrite", action="store_true",
help="If present, overwrites chosen config with current env variables")
parser.add_argument("-s", "--disable-spinner", action="store_true", required=False,
help="Disables spinner")

args = parser.parse_args()

Expand Down Expand Up @@ -404,8 +417,8 @@ def spinner(msg):
signal.signal(signal.SIGINT, cleanup_and_exit)

# Build, run, then follow all logs. Begin monitoring process
build_containers(f'.build-files/{args.env_file}')
start_containers(f'.build-files/{args.env_file}')
build_containers(f'.build-files/{args.env_file}', args.disable_spinner)
start_containers(f'.build-files/{args.env_file}', args.disable_spinner)
follow_all_logs(logs_path, services, args.verbose, args.detached)
check_containers_status(services, args.detached)
else:
Expand Down

0 comments on commit ec8ad17

Please sign in to comment.