generated from hack4impact/flask-base
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
0 parents
commit 717203e
Showing
87 changed files
with
22,118 additions
and
0 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,28 @@ | ||
backend/.webassets-cache/ | ||
backend/webassets-external/ | ||
backend/config/data-dev.sqlite | ||
backend/.DS_Store | ||
backend/*.pyc | ||
backend/*.pyo | ||
backend/env | ||
backend/venv | ||
backend/*.env | ||
backend/env* | ||
backend/dist | ||
backend/*.egg | ||
backend/*.egg-info | ||
backend/*.sqlite | ||
backend/.idea | ||
backend/dump.rdb | ||
backend/.vscode/ | ||
backend/app/storage | ||
backend/migrations/ | ||
backend/config/ | ||
backend/.ftpconfig | ||
backend/.ftpignore | ||
|
||
frontend/node_modules | ||
frontned/.gitignore | ||
fronend/.gitignore | ||
|
||
.git |
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,6 @@ | ||
.github | ||
.vscode | ||
sql_app.db | ||
venv | ||
*.db | ||
node_modules |
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 @@ | ||
ycht.tech |
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,76 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as | ||
contributors and maintainers pledge to making participation in our project and | ||
our community a harassment-free experience for everyone, regardless of age, body | ||
size, disability, ethnicity, sex characteristics, gender identity and expression, | ||
level of experience, education, socio-economic status, nationality, personal | ||
appearance, race, religion, or sexual identity and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment | ||
include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or | ||
advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic | ||
address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable | ||
behavior and are expected to take appropriate and fair corrective action in | ||
response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. Examples of | ||
representing a project or community include using an official project e-mail | ||
address, posting via an official social media account, or acting as an appointed | ||
representative at an online or offline event. Representation of a project may be | ||
further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting the project team at info@selfhosted.pro. All | ||
complaints will be reviewed and investigated and will result in a response that | ||
is deemed necessary and appropriate to the circumstances. The project team is | ||
obligated to maintain confidentiality with regard to the reporter of an incident. | ||
Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good | ||
faith may face temporary or permanent repercussions as determined by other | ||
members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, | ||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html | ||
|
||
[homepage]: https://www.contributor-covenant.org | ||
|
||
For answers to common questions about this code of conduct, see | ||
https://www.contributor-covenant.org/faq |
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,53 @@ | ||
# Build Vue | ||
FROM node:14.5.0-alpine as build-stage | ||
WORKDIR /app | ||
COPY ./frontend/package*.json ./ | ||
RUN npm install | ||
COPY ./frontend/ . | ||
RUN npm run build | ||
|
||
# Setup Container and install Flask | ||
FROM lsiobase/alpine:3.12 as deploy-stage | ||
# MAINTANER Your Name "info@selfhosted.pro" | ||
|
||
# Set Variables | ||
ENV FLASK_CONFIG=production | ||
ENV PYTHONIOENCODING=UTF-8 | ||
|
||
WORKDIR /api | ||
COPY ./backend/requirements.txt . | ||
|
||
# Install Dependancies | ||
RUN \ | ||
echo "**** install build packages ****" && \ | ||
apk add --no-cache --virtual=build-dependencies \ | ||
g++ \ | ||
make \ | ||
python3-dev \ | ||
libffi-dev \ | ||
ruby-dev &&\ | ||
echo "**** install packages ****" && \ | ||
apk add --no-cache \ | ||
python3 \ | ||
py3-pip \ | ||
nginx &&\ | ||
gem install sass &&\ | ||
echo "**** Installing Python Modules ****" && \ | ||
pip3 install -r requirements.txt &&\ | ||
echo "**** Cleaning Up ****" &&\ | ||
apk del --purge \ | ||
build-dependencies && \ | ||
rm -rf \ | ||
/root/.cache \ | ||
/tmp/* | ||
|
||
COPY ./backend/api . | ||
COPY root / | ||
|
||
# Vue | ||
COPY --from=build-stage /app/dist /app | ||
COPY nginx.conf /config/nginx/nginx.conf | ||
|
||
# Expose | ||
VOLUME /config | ||
EXPOSE 8000 |
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 @@ | ||
Copyright 2020 SelfhostedPro | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,53 @@ | ||
![logo](https://raw.githubusercontent.com/SelfhostedPro/Yacht/vue/readme_media/Yacht_logo_1_dark.png "templates") | ||
## Yacht | ||
Yacht is a container management UI with a focus on templates and 1-click deployments. | ||
|
||
## Demo: | ||
![Tempaltes](https://raw.githubusercontent.com/SelfhostedPro/Yacht/vue/readme_media/Yacht-Demo.gif "templates") | ||
|
||
## Installation: | ||
Currently only linux has been verified as working but we are open to the idea of supporting windows eventually as well. | ||
|
||
**Keep in mind, this is a pre-alpha so the risk of data loss is real and it may not be stable** | ||
|
||
Once docker is installed you'll simply run the following commands to get started: | ||
``` | ||
docker volume create yacht | ||
docker run -d -p 8000:8000 -v /var/run/docker.sock:/var/run/docker.sock -v yacht:/config selfhostedpro/yacht:vue | ||
``` | ||
It will be available on port 8000. | ||
|
||
The default login is `admin@yacht.local` and `pass` you should change this immediately by clicking on admin in the top right and then "User" then select "Change Password" in the top menu. You can also change your username using this field. | ||
|
||
If you need to reset your password/username to the included defaults, you can connect to the container using `docker exec -it "INSERT CONTAINER ID HERE WITHOUT QUOTES" /bin/bash` then run `python3 /manage.py recreate_db`. | ||
|
||
## Features So Far: | ||
* Container Templating Compatibility (Portainer Compatible) | ||
* Vuetify UI Framework | ||
* Basic Container Management | ||
* Template Framework | ||
* Easy Template Updating | ||
* Centralized settings for volume management and similar QOL functionality. | ||
|
||
|
||
## Planned Features: | ||
* Advanced Container Management (Edit/Modify) | ||
* Container Monitoring | ||
* Docker-Compose Compatibility | ||
* Easy access to container interfaces | ||
* User Management | ||
|
||
*If you want something that's not planned please open a feature request issue and we'll see about getting it added.* | ||
|
||
## Templating: | ||
Currently Yacht is compatible with portainer templates. You'll add a template url in the "Add Template" settings. The the template will be read, separated into apps, and imported into the database. The apps associated with the templates are linked via a db relationship so when the template is removed, so are the apps associated with it. We store the template url as well so we can enable updating templates with a button press. | ||
|
||
We recommend starting with: | ||
``` | ||
https://raw.githubusercontent.com/SelfhostedPro/selfhosted_templates/yacht/Template/template.json | ||
``` | ||
|
||
In templates you are able to define variables (starting with `!`) to have them automatically replaced by whatever variable the user has set in their server settings (ie. `!config` will be replaced by `/yacht/AppData/Config` by default). | ||
|
||
## License | ||
[MIT License](LICENSE.md) |
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 @@ | ||
theme: jekyll-theme-slate |
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,24 @@ | ||
.webassets-cache/ | ||
webassets-external/ | ||
config/data-dev.sqlite | ||
.DS_Store | ||
*.pyc | ||
*.pyo | ||
env | ||
venv | ||
*.env | ||
env* | ||
dist | ||
*.egg | ||
*.egg-info | ||
*.sqlite | ||
.idea | ||
dump.rdb | ||
.vscode/ | ||
app/storage | ||
migrations/ | ||
config/ | ||
|
||
|
||
.ftpconfig | ||
.ftpignore |
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 @@ | ||
from .apps import * |
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,108 @@ | ||
from sqlalchemy.orm import Session | ||
from sqlalchemy.exc import IntegrityError | ||
|
||
from ..db import models, schemas | ||
from ..utils import * | ||
|
||
from datetime import datetime | ||
import docker | ||
|
||
def get_apps(): | ||
apps_list = [] | ||
dclient = docker.from_env() | ||
apps = dclient.containers.list(all=True) | ||
for app in apps: | ||
attrs=app.attrs | ||
attrs.update(conv2dict('name', app.name)) | ||
attrs.update(conv2dict('ports', app.ports)) | ||
attrs.update(conv2dict('short_id', app.short_id)) | ||
apps_list.append(attrs) | ||
|
||
return apps_list | ||
|
||
def get_app(app_name): | ||
dclient = docker.from_env() | ||
app = dclient.containers.get(app_name) | ||
attrs = app.attrs | ||
|
||
attrs.update(conv2dict('ports', app.ports)) | ||
attrs.update(conv2dict('short_id', app.short_id)) | ||
attrs.update(conv2dict('name', app.name)) | ||
|
||
return attrs | ||
|
||
def get_app_processes(app_name): | ||
dclient = docker.from_env() | ||
app = dclient.containers.get(app_name) | ||
if app.status == 'running': | ||
processes = app.top() | ||
return schemas.Processes(Processes=processes['Processes'], Titles=processes['Titles']) | ||
else: | ||
return None | ||
|
||
def get_app_logs(app_name): | ||
dclient = docker.from_env() | ||
app = dclient.containers.get(app_name) | ||
if app.status == 'running': | ||
return schemas.AppLogs(logs=app.logs()) | ||
else: | ||
return None | ||
|
||
def deploy_app(template: schemas.DeployForm): | ||
try: | ||
launch = launch_app( | ||
template.name, | ||
template.image, | ||
conv_restart2data(template.restart_policy), | ||
conv_ports2data(template.ports), | ||
conv_volumes2data(template.volumes), | ||
conv_env2data(template.env), | ||
conv_sysctls2data(template.sysctls), | ||
conv_caps2data(template.cap_add) | ||
) | ||
|
||
|
||
except Exception as exc: raise | ||
print('done deploying') | ||
|
||
return schemas.DeployLogs(logs=launch.logs()) | ||
|
||
def launch_app(name, image, restart_policy, ports, volumes, env, sysctls, caps): | ||
dclient = docker.from_env() | ||
lauch = dclient.containers.run( | ||
name=name, | ||
image=image, | ||
restart_policy=restart_policy, | ||
ports=ports, | ||
volumes=volumes, | ||
environment=env, | ||
sysctls=sysctls, | ||
cap_add=caps, | ||
detach=True | ||
) | ||
print(lauch) | ||
print(f'''Container started successfully. | ||
Name: {name}, | ||
Image: {image}, | ||
Ports: {ports}, | ||
Volumes: {volumes}, | ||
Env: {env}''') | ||
return lauch | ||
|
||
def app_action(app_name, action): | ||
err = None | ||
dclient = docker.from_env() | ||
app = dclient.containers.get(app_name) | ||
_action = getattr(app, action) | ||
if action == 'remove': | ||
try: | ||
_action(force=True) | ||
except Exception as exc: | ||
err = f"{exc}" | ||
else: | ||
try: | ||
_action() | ||
except Exception as exc: | ||
err = exc.explination | ||
apps_list = get_apps() | ||
return apps_list |
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 @@ | ||
from .auth import * |
Oops, something went wrong.