~sirn/fanboi2

71df07ff3017feab70f9675e396ea13fc414ecbc — Kridsada Thanabulpong 11 months ago a3329d2
[cmd/deploy] switch fbdeploy to use python -m venv
3 files changed, 29 insertions(+), 18 deletions(-)

M .build.yml
M .gitignore
M fanboi2/cmd/deploy.py
M .build.yml => .build.yml +23 -1
@@ 6,11 6,15 @@ packages:
  - postgresql10-server
  - py36-pip
  - py36-sqlite3
  - py36-virtualenv
  - python3
  - python36
sources:
  - https://git.sr.ht/~sirn/fanboi2
secrets:
  - 1628f803-8887-41bc-9044-d8e909dcc77b
environment:
  deploy_ref: refs/heads/master
  deploy_repo: https://git.sr.ht/~sirn/fanboi2
tasks:
  - setup: |
      cd fanboi2/ || exit 1


@@ 48,3 52,21 @@ tasks:

      poetry build --format=sdist
      tar -tvzf dist/fanboi2-*.tar.gz

      local_ref=$(git rev-parse HEAD)
      remote_ref=$(git ls-remote $deploy_repo $deploy_ref | awk '{ print $1 }')

      if [ "$local_ref" != "$remote_ref" ]; then
        complete-build
      fi
  - deploy: |
      cd fanboi2/ || exit 1
      export PATH=$HOME/.local/bin:$PATH

      poetry install --extras=deploy
      poetry run fbdeploy \
        --path=/srv/fanboi2 \
        --user=fanboi2 \
        --postcmd=/srv/fanboi2/postcmd \
        --port=4022 \
        $(host -t A app.targets.fanboi.ch | awk '{ print $4 }')

M .gitignore => .gitignore +3 -2
@@ 5,9 5,7 @@ Thumbs.db
# Application runtime
static/
tmp/
.eggs/
*.dump
*.egg-info/
*.env
*.log
*.pyc


@@ 16,7 14,10 @@ tmp/
celerybeat*

# Building
*.egg-info/
.eggs/
dist/
setup.py

# Assets
node_modules/

M fanboi2/cmd/deploy.py => fanboi2/cmd/deploy.py +3 -15
@@ 21,10 21,7 @@ from ..version import __VERSION__
TS = datetime.datetime.utcnow().strftime("%Y%m%d%H%M%S")


REQUIRED_BINS = (
    ("python3", ("python3.6", "python-3.6")),
    ("virtualenv", ("virtualenv3.6", "virtualenv-3.6", "virtualenv")),
)
REQUIRED_BINS = (("python3", ("python3.6", "python-3.6")),)


#


@@ 213,18 210,9 @@ def _setup_app(conn, srcdir, hostmeta, sudo_user=None):
    try:
        with conn.cd(srcdir):
            run_as(
                conn,
                sudo_user,
                [
                    hostmeta["virtualenv"],
                    "-p",
                    hostmeta["python3"],
                    "--always-copy",
                    "venv",
                ],
                hide=True,
                conn, sudo_user, [hostmeta["python3"], "-m", "venv", "venv"], hide=True
            )
            run_as(conn, sudo_user, ["venv/bin/pip3", "install", "-e", "."], hide=True)
            run_as(conn, sudo_user, ["venv/bin/pip", "install", "-e", "."], hide=True)
    except UnexpectedExit as e:
        echo("failed\n\n")
        fail(e, "setup application")