Compare commits

..

1 commit

Author SHA1 Message Date
missytake e7a7aaeb37 added pyinfra method to deploy wordpress 2024-03-10 22:41:32 +01:00
2 changed files with 26 additions and 12 deletions

View file

@ -5,10 +5,10 @@ StartLimitIntervalSec=0
[Service]
Type=simple
ExecStart=/usr/bin/podman run --rm --name={{name}} {{environment}} {{mount}} {{port}} {{container}}:{{version}}
ExecStart=/usr/bin/podman run --rm --name={{container_name}} {{environment}} {{mount}} {{port}} docker.io/library/{{container}}:{{version}}
EnvironmentFile=%h/.env
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target

View file

@ -15,6 +15,8 @@ def deploy_wordpress(
mysql_root_password: str = None,
_su: dict = {},
):
if not mysql_root_password:
mysql_root_password = mysql_password
# check that podman is installed
secrets = [
f"MYSQL_PASSWORD={mysql_password}",
@ -38,10 +40,21 @@ def deploy_wordpress(
"ufw allow 443",
"ufw allow 80",
"ufw allow 22",
"ufw allow 42022",
"ufw status",
# "ufw reload?",
],
)
files.directory(
name="create db_data directory",
path=f"/home/{unix_user}/db_data",
**_su,
)
files.directory(
name="create wp-content directory",
path=f"/home/{unix_user}/wp-content",
**_su,
)
print(importlib.resources.files(__package__))
service_path = f"/home/{unix_user}/.config/systemd/user/"
@ -58,12 +71,12 @@ def deploy_wordpress(
files.template(
name="upload wordpress systemd service",
src=importlib.resources.files(__package__) / "podman.service.j2",
dest=f"{service_path}wordpress.service",
dest=f"{service_path}{domain}_wp.service",
description="run wordpress podman container",
name=f"{domain}_wp",
container_name=f"{domain}_wp",
environment="-e " + " -e ".join(environment),
mount="--mount " + " --mount ".join(mount),
port=f"-p 127.0.0.1:{nginx_port}:80"
port=f"-p 127.0.0.1:{wordpress_port}:80",
container="wordpress",
version=wordpress_version,
**_su,
@ -78,12 +91,12 @@ def deploy_wordpress(
files.template(
name="upload mysql systemd service",
src=importlib.resources.files(__package__) / "podman.service.j2",
dest=f"{service_path}mysql.service",
dest=f"{service_path}{domain}_db.service",
description="run mysql podman container",
name=f"{domain}_db",
container_name=f"{domain}_db",
environment="-e " + " -e ".join(environment),
mount=f"--mount type=bind,source=/home/{unix_user}/db_data/_data/,destination=/var/lib/mysql",
port=f"-p {mysql_port}:3306"
mount=f"--mount type=bind,source=/home/{unix_user}/db_data,destination=/var/lib/mysql",
port=f"-p {mysql_port}:3306",
container="mysql",
version="5.7",
**_su,
@ -106,4 +119,5 @@ def deploy_wordpress(
daemon_reload=True,
user_name=unix_user,
user_mode=True,
**_su,
)