-
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.
- Loading branch information
Showing
10 changed files
with
627 additions
and
30 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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
FROM canopytax/python-base | ||
|
||
RUN apk --update add nodejs && \ | ||
RUN apk --no-cache add nodejs && \ | ||
cd /app/tmeister/static && \ | ||
npm install && \ | ||
npm run build && \ | ||
apk del nodejs && \ | ||
cd /app && \ | ||
rm -rf /var/cache/apk/* | ||
cd /app | ||
|
||
|
||
EXPOSE 8445 |
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,98 @@ | ||
import sys | ||
import os | ||
|
||
from invoke import task | ||
# You might need the following line so that alembic can traverse | ||
# the application properly | ||
# export PYTHONPATH=$(pwd) | ||
|
||
IS_TTY = False if os.getenv('DOCKER') else sys.stdout.isatty() | ||
|
||
@task | ||
def clean(ctx): | ||
patterns = ( | ||
'**/*.pyc', | ||
'**/__pycache__', | ||
'.cache', | ||
) | ||
|
||
for pattern in patterns: | ||
ctx.run("rm -rf {}".format(pattern)) | ||
|
||
|
||
@task | ||
def lint(ctx, full=False): | ||
if full: | ||
ctx.run('python3 -m pylint tmeister migrate tests', pty=IS_TTY) | ||
else: | ||
ctx.run('python3 -m flake8 tmeister migrate tests', pty=IS_TTY) | ||
|
||
|
||
@task(pre=[clean]) | ||
def test(ctx, coverage=True, x=False, v=False): | ||
""" | ||
test the code! | ||
:param ctx: | ||
:param headless: | ||
:param coverage: use --no-coverage to skip coverage results | ||
:param x: use -x to stop at first test | ||
:param v: use -v to increase verbosity | ||
:return: | ||
""" | ||
cmd = 'python3 -m pytest --color yes' | ||
if coverage: | ||
print("coverage added") | ||
cmd += ' --cov=tmeister' | ||
|
||
if x: | ||
cmd += ' -x' | ||
|
||
if not v: | ||
cmd += ' --quiet' | ||
|
||
ctx.run(cmd, pty=IS_TTY) | ||
|
||
|
||
@task | ||
def install(ctx): | ||
""" | ||
install dependencies | ||
NOT to be used in docker. Only for local dev | ||
:param ctx: | ||
:param docker: if this is installing in a docker container | ||
""" | ||
ctx.run('python3 -m pip install -r requirements.txt -t .pip', pty=IS_TTY) | ||
|
||
|
||
@task | ||
def serve(ctx): | ||
ctx.run('python3 run.py', pty=IS_TTY) | ||
|
||
|
||
@task | ||
def migrate(ctx): | ||
ctx.run('alembic upgrade head', pty=IS_TTY) | ||
|
||
|
||
@task | ||
def down(ctx, all=False): | ||
if all: | ||
num = 'base' | ||
else: | ||
num = '-1' | ||
ctx.run('alembic downgrade ' + num, pty=IS_TTY) | ||
|
||
|
||
@task(pre=[migrate]) | ||
def seed(ctx): | ||
print('no seed script yet') | ||
|
||
|
||
@task | ||
def run(ctx): | ||
ctx.run('python3 run.py', pty=IS_TTY) | ||
|
||
|
||
@task | ||
def hooks(ctx): | ||
ctx.run('ln -sf $(pwd)/hooks/pre-commit.sh .git/hooks/pre-commit') |
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,6 +1,5 @@ | ||
""" | ||
These are api tests that are completely stand-alone. | ||
They have no dependencies to service code, and are designed to enforce the api contract. | ||
They have no dependencies to service code, | ||
and are designed to enforce the api contract. | ||
""" | ||
|
||
|
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
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 |
---|---|---|
|
@@ -110,15 +110,3 @@ def main(): | |
|
||
if __name__ == '__main__': | ||
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
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,108 @@ | ||
box: canopytax/python-base | ||
build: | ||
services: | ||
- id: canopytax/postgresdb | ||
tag: latest | ||
username: $DOCKER_USERNAME | ||
password: $DOCKER_PASSWORD | ||
|
||
steps: | ||
- script: | ||
name: pip install | ||
code: | | ||
mv "$WERCKER_CACHE_DIR/pip" /root/.local || echo "Nothing in cache" | ||
pip3 install -r requirements.txt --user -U | ||
cp -a /root/.local "$WERCKER_CACHE_DIR/pip" || "nothing to copy" | ||
- script: | ||
name: build UI | ||
code: | | ||
apk --no-cache add nodejs | ||
cd /app/tmeister/static | ||
npm run build | ||
apk del nodejs | ||
cd /app | ||
- script: | ||
name: lint | ||
code: | | ||
invoke lint | ||
- script: | ||
name: run tests | ||
code: | | ||
invoke test -x | ||
- script: | ||
name: clean and copy files | ||
code: | | ||
invoke clean | ||
mv /root/.local .pip | ||
dockerhub: | ||
steps: | ||
- script: | ||
name: get tags | ||
code: | | ||
if [ $WERCKER_GIT_BRANCH == 'master' ]; then export DOCKER_BRANCH=latest; else export DOCKER_BRANCH="$(basename $WERCKER_GIT_BRANCH)"; fi; | ||
echo $DOCKER_BRANCH | ||
- script: | ||
name: prepare for dockerhub | ||
code: | | ||
# put pip files back in place | ||
mv .pip /root/.local | ||
# clean unneeded files | ||
rm -rf .git/ | ||
rm .gitignore | ||
rm wercker.yml | ||
rm readme.md | ||
rm requirements.txt | ||
rm .pylintrc | ||
rm .coverage | ||
rm Dockerfile | ||
rm docker-compose.yml | ||
rm -rf tests/ | ||
rm -rf tmeister/static/node_modules | ||
rm -rf tmeister/static/spec | ||
rm -rf tmeister/static/src | ||
rm -rf tmeister/static/bin | ||
# move files | ||
cp -a . /app | ||
# clean wercker files | ||
cd /app | ||
rm -rf /pipeline/ | ||
# recreate output dir | ||
mkdir -p "$WERCKER_OUTPUT_DIR" | ||
#mkdir -p "$WERCKER_ROOT" | ||
touch "$WERCKER_OUTPUT_DIR/touch" | ||
- internal/docker-push: | ||
repository: $REPO | ||
tag: $WERCKER_GIT_COMMIT $DOCKER_BRANCH | ||
ports: "9191" | ||
username: $DOCKER_USERNAME | ||
password: $DOCKER_PASSWORD | ||
cmd: 'dumb-init ./startup.sh' | ||
|
||
deploy: | ||
box: | ||
id: canopytax/deployment | ||
username: $DOCKER_USERNAME | ||
password: $DOCKER_PASSWORD | ||
tag: latest | ||
steps: | ||
- script: | ||
name: run migration | ||
code: | | ||
echo "placeholder" | ||
- script: | ||
name: deploy to rancher | ||
code: | | ||
/scripts/deploy-to-rancher.py --docker-tag "$WERCKER_GIT_COMMIT" | ||