-
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.
Merge pull request #99 from EyeSeeTea/development
Release 1.10.0
- Loading branch information
Showing
24 changed files
with
511 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FLASK_ENV=production | ||
FLASK_APP=src/d2_docker/api/main.py |
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,2 @@ | ||
HARBOR_USER=user | ||
HARBOR_PASSWORD=1234 |
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 |
---|---|---|
|
@@ -107,3 +107,5 @@ venv.bak/ | |
*.code-workspace | ||
.vscode | ||
*.war | ||
|
||
.flaskenv.secret |
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,10 @@ | ||
FROM ubuntu:20.04 | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update | ||
RUN apt-get install -y vim netcat git docker.io docker-compose python3 python3-pip | ||
COPY . /app/d2-docker | ||
RUN pip3 install /app/d2-docker | ||
|
||
ENTRYPOINT ["/app/d2-docker/docker-container/start.sh"] | ||
CMD [] |
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,7 @@ | ||
#!/bin/bash | ||
set -e -u -o pipefail | ||
|
||
image_name="eyeseetea/d2-docker-container" | ||
version=$(./d2-docker-dev.sh version | grep "^d2-docker" | awk '{print $3}') | ||
docker build -t "$image_name:$version" . | ||
docker image tag "$image_name:$version" "$image_name:latest" |
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,3 @@ | ||
#!/bin/bash | ||
export PYTHONPATH=src | ||
exec python3 $PYTHONPATH/d2_docker/cli.py "$@" |
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,2 @@ | ||
#!/bin/bash | ||
exec docker exec docker-container-d2-docker-1 d2-docker "$@" |
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,13 @@ | ||
version: "3" | ||
services: | ||
d2-docker: | ||
image: eyeseetea/d2-docker-container:latest | ||
restart: unless-stopped | ||
ports: | ||
- 5000:5000 | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- ./shared:/app/shared | ||
environment: | ||
ROOT_PATH: $PWD/shared/d2-docker | ||
VOLUMES_OWNERSHIP: ${HOST_UID}:${HOST_GID} |
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 @@ | ||
#!/bin/bash -x | ||
set -e -u -o pipefail | ||
|
||
get_script_dir() { | ||
(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
} | ||
|
||
expose_d2_docker_to_host() { | ||
script_dir=$(get_script_dir) | ||
cp -av "$script_dir/../src/d2_docker/." "/app/shared/d2-docker" | ||
} | ||
|
||
start_api() { | ||
d2-docker api start | ||
} | ||
|
||
fix_volumes_ownership() { | ||
if test "$VOLUMES_OWNERSHIP" -a "$VOLUMES_OWNERSHIP" != ":"; then | ||
chown -R "$VOLUMES_OWNERSHIP" /app/shared/ | ||
fi | ||
} | ||
|
||
main() { | ||
expose_d2_docker_to_host | ||
fix_volumes_ownership | ||
start_api | ||
} | ||
|
||
main |
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,3 @@ | ||
Flask==2.0.3 | ||
python-dotenv | ||
Flask_Cors==3.0.10 |
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
Empty 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
import base64 | ||
from d2_docker.commands import list_ | ||
from flask import jsonify | ||
from dotenv import dotenv_values | ||
|
||
|
||
class Struct(object): | ||
def __init__(self, dictionary): | ||
self.__dict__.update(dictionary) | ||
|
||
def __getattr__(self, item): | ||
return None | ||
|
||
def __repr__(self): | ||
pairs = ", ".join("{}={}".format(k, repr(v)) for (k, v) in self.__dict__.items()) | ||
return "Struct(" + pairs + ")" | ||
|
||
|
||
def get_args_from_request(request): | ||
body = request.get_json() | ||
args = Struct(body) | ||
return args | ||
|
||
|
||
def get_auth_headers(user, password): | ||
encoded_auth = base64.b64encode((user + ":" + password).encode()).decode() | ||
return {"Authorization": "Basic " + encoded_auth} | ||
|
||
|
||
def get_container(name): | ||
containers = list_.get_containers() | ||
return next((c for c in containers if c["name"] == name), None) | ||
|
||
|
||
def success(): | ||
return jsonify(dict(status="SUCCESS")) | ||
|
||
|
||
def server_error(message, status=500): | ||
body = jsonify(dict(status="ERROR", error=message)) | ||
return (body, status) | ||
|
||
|
||
def get_config(): | ||
return { | ||
**dotenv_values(".flaskenv"), | ||
**dotenv_values(".flaskenv.secret"), | ||
**os.environ, | ||
} |
Oops, something went wrong.