-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created initial docker automated workflow
- Loading branch information
Showing
9 changed files
with
91 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 @@ | ||
dockerfiles |
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,21 @@ | ||
version: "3.8" | ||
|
||
services: | ||
#fetches dockerfiles e.g. ./seeds.yaml => ./dockerfiles/astro-big-doc.Dockerfile,... | ||
seeds: | ||
build: | ||
context: ./seeds | ||
volumes: | ||
- ./dockerfiles:/dockerfiles | ||
astro-big-doc: | ||
build: | ||
context: ./dockerfiles | ||
dockerfile: astro-big-doc.Dockerfile | ||
volumes: | ||
- ../content:/astro-big-doc/content | ||
- ../public:/astro-big-doc/public | ||
- ../menu.yaml:/astro-big-doc/menu.yaml | ||
- ../dist:/astro-big-doc/dist | ||
ports: | ||
- "3001:3001" | ||
- "4321:4321" |
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,21 @@ | ||
import sys | ||
import subprocess | ||
import os | ||
|
||
# Path to the directory containing docker-compose.yml | ||
docker_compose_dir = os.path.join(os.path.dirname(__file__)) | ||
|
||
# Default command if no argument is provided | ||
command = "build" | ||
|
||
# Check if an argument is provided and use it as the command | ||
if len(sys.argv) > 1: | ||
command = sys.argv[1] | ||
|
||
# Change the working directory | ||
os.chdir(docker_compose_dir) | ||
|
||
if(command == "build"): | ||
subprocess.run(["docker-compose", "run", "--rm", "astro-big-doc", "build"]) | ||
elif(command == "init"): | ||
subprocess.run(["docker-compose", "run", "--rm", "seeds"]) |
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,17 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.9-slim | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Install Python dependencies | ||
RUN pip install pyyaml requests | ||
|
||
# Copy the Python script into the container at /app | ||
COPY fetch.py /app/ | ||
|
||
# Copy the YAML file containing the mappings into the container at /app | ||
COPY seeds.yaml /app/ | ||
|
||
# Command to run the fetch script | ||
CMD ["python", "fetch.py", "seeds.yaml"] |
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,29 @@ | ||
import yaml | ||
import requests | ||
import sys | ||
|
||
def fetch_and_save_dockerfiles(yaml_input): | ||
# Load the YAML data from string | ||
dockerfile_mappings = yaml.safe_load(yaml_input) | ||
|
||
for item in dockerfile_mappings: | ||
for key, url in item.items(): | ||
# Fetch the Dockerfile from the URL | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
# Save the Dockerfile content to a file named <key>.Dockerfile | ||
filename = f"/dockerfiles/{key}.Dockerfile" | ||
with open(filename, 'w') as file: | ||
file.write(response.text) | ||
print(f"Saved {filename}") | ||
else: | ||
print(f"Failed to fetch {url} with status code {response.status_code}") | ||
|
||
if __name__ == "__main__": | ||
# Assume the YAML data is passed as a command line argument | ||
if len(sys.argv) > 1: | ||
with open(sys.argv[1], 'r') as file: | ||
yaml_input = file.read() | ||
fetch_and_save_dockerfiles(yaml_input) | ||
else: | ||
print("Please provide a file path to the YAML input as an argument.") |
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 @@ | ||
- astro-big-doc: https://raw.githubusercontent.com/MicroWebStacks/astro-big-doc/main/Dockerfile |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,12 +1,2 @@ | ||
@echo off | ||
setlocal | ||
|
||
:: Default command if no argument is provided | ||
set COMMAND=build | ||
|
||
:: Check if an argument is provided and use it as the command | ||
if not "%~1"=="" set COMMAND=%~1 | ||
|
||
:: Run the Docker Compose command | ||
docker-compose run --rm astro-doc %COMMAND% | ||
endlocal | ||
python containers\run.py %* |