8 Commits

Author SHA1 Message Date
Max
24a1931c47 feat: stuff 2025-12-22 10:14:31 -05:00
Max
2827653bd5 feat: works on production 2025-02-19 00:57:32 -05:00
Max
44e1d6d0e6 feat: S3 storage for development environmne 2025-02-18 23:25:42 -05:00
Max
225489f678 feat: change security group tags, not name 2025-02-18 15:18:20 -05:00
Max
53ad9c161c feat: added tags to parts of vpc module, to use with proxy 2025-02-18 15:16:06 -05:00
Max
d961d8ffb6 fix: no ds_store 2025-02-13 22:09:15 -05:00
Max
aa7c0d4dee fix: gitignore is proper 2025-02-13 22:08:34 -05:00
Max
093368f6fb chore: requirements.txt is correct now 2025-02-13 22:07:37 -05:00
11 changed files with 234 additions and 20 deletions

174
.gitignore vendored
View File

@@ -37,7 +37,179 @@ override.tf.json
.terraformrc .terraformrc
terraform.rc terraform.rc
# ---> Ansible
*.retry
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
*secret* *secret*
.vscode .vscode
.env
.DS_Store .DS_Store

View File

@@ -4,7 +4,9 @@ includes:
tf: { taskfile: terraform, dir: terraform } tf: { taskfile: terraform, dir: terraform }
tasks: tasks:
dev: docker compose -f compose.dev.yml up --build --force-recreate --no-deps dev:
- docker compose -f compose.dev.yml rm -fsv
- docker compose -f compose.dev.yml up --build --force-recreate --no-deps
deploy:fast: ansible-playbook playbooks/fast.yml deploy:fast: ansible-playbook playbooks/fast.yml
deploy:slow: ansible-playbook playbooks/slow.yml deploy:slow: ansible-playbook playbooks/slow.yml

View File

@@ -3,8 +3,10 @@ services:
# Gitea itself. # Gitea itself.
gitea: gitea:
container_name: web-git-instance container_name: web-git-instance
restart: unless-stopped
depends_on: depends_on:
- backup - backup
- bucket-script
build: build:
context: gitea context: gitea
dockerfile: Dockerfile.dev dockerfile: Dockerfile.dev
@@ -31,7 +33,7 @@ services:
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
environment: environment:
AWS_ENDPOINT: localstack:4566 AWS_ENDPOINT: localstack:4566
AWS_S3_BUCKET_NAME: test AWS_S3_BUCKET_NAME: backup
AWS_ACCESS_KEY_ID: _ AWS_ACCESS_KEY_ID: _
AWS_SECRET_ACCESS_KEY: _ AWS_SECRET_ACCESS_KEY: _
BACKUP_CRON_EXPRESSION: "* * * * *" BACKUP_CRON_EXPRESSION: "* * * * *"
@@ -59,7 +61,11 @@ services:
AWS_ACCESS_KEY_ID: _ AWS_ACCESS_KEY_ID: _
AWS_SECRET_ACCESS_KEY: _ AWS_SECRET_ACCESS_KEY: _
AWS_ENDPOINT_URL: http://localstack:4566 AWS_ENDPOINT_URL: http://localstack:4566
command: '"aws s3api create-bucket --bucket test"' command: |
"
aws s3api create-bucket --bucket backup
aws s3api create-bucket --bucket storage
"
volumes: volumes:
data: data:

View File

@@ -3,6 +3,8 @@ FROM gitea/gitea:latest-rootless
ADD --chown=git:git config /etc/gitea ADD --chown=git:git config /etc/gitea
ADD --chown=git:git custom /etc/gitea-custom ADD --chown=git:git custom /etc/gitea-custom
ENV GITEA_CUSTOM=/etc/gitea-custom
RUN rm /etc/gitea/app.ini RUN rm /etc/gitea/app.ini
RUN mv /etc/gitea/dev.app.ini /etc/gitea/app.ini RUN mv /etc/gitea/dev.app.ini /etc/gitea/app.ini

View File

@@ -94,3 +94,10 @@ DEFAULT_MERGE_STYLE = merge
[repository.signing] [repository.signing]
DEFAULT_TRUST_MODEL = committer DEFAULT_TRUST_MODEL = committer
[storage]
STORAGE_TYPE = minio
MINIO_ENDPOINT = s3.us-east-1.amazonaws.com
MINIO_BUCKET = myrica-faya
MINIO_USE_SSL = true
MINIO_INSECURE_SKIP_VERIFY = false

View File

@@ -32,8 +32,8 @@ PROTOCOL = https
ROOT_URL = https://localhost:443/ ROOT_URL = https://localhost:443/
DOMAIN = localhost DOMAIN = localhost
HTTP_PORT = 443 HTTP_PORT = 443
CERT_FILE = cert.pem CERT_FILE = /etc/gitea-custom/cert.pem
KEY_FILE = key.pem KEY_FILE = /etc/gitea-custom/key.pem
[database] [database]
DB_TYPE = sqlite3 DB_TYPE = sqlite3
@@ -95,3 +95,12 @@ DEFAULT_TRUST_MODEL = committer
[oauth2] [oauth2]
JWT_SECRET = x-----------------------------------------x JWT_SECRET = x-----------------------------------------x
[storage]
STORAGE_TYPE = minio
MINIO_ENDPOINT = localstack:4566
MINIO_ACCESS_KEY_ID = test
MINIO_SECRET_ACCESS_KEY = test
MINIO_BUCKET = storage
MINIO_USE_SSL = false
MINIO_INSECURE_SKIP_VERIFY = true

View File

@@ -52,7 +52,7 @@
state: started state: started
recreate: true recreate: true
restart_policy: unless-stopped restart_policy: unless-stopped
memory: 425m memory: 300m
memory_swap: 900m memory_swap: 900m
ports: [80:80, 2222:2222, 443:443, "22:22"] ports: [80:80, 2222:2222, 443:443, "22:22"]
env: env:
@@ -63,6 +63,8 @@
GITEA__server__SSH_DOMAIN: "{{ full_domain.value }}" GITEA__server__SSH_DOMAIN: "{{ full_domain.value }}"
GITEA__server__DOMAIN: "{{ full_domain.value }}" GITEA__server__DOMAIN: "{{ full_domain.value }}"
GITEA__server__ROOT_URL: "https://{{ full_domain.value }}/" GITEA__server__ROOT_URL: "https://{{ full_domain.value }}/"
GITEA__storage__MINIO_ACCESS_KEY_ID: "{{ minio_access_key }}"
GITEA__storage__MINIO_SECRET_ACCESS_KEY: "{{ minio_secret_key }}"
labels: labels:
docker-volume-backup.stop-during-backup: "true" docker-volume-backup.stop-during-backup: "true"
volumes: volumes:

View File

@@ -11,22 +11,17 @@
rebuild: always rebuild: always
pull: true pull: true
- name: Make temp file.
ansible.builtin.tempfile:
suffix: .tar
register: tar_file
- name: Push image to archive. - name: Push image to archive.
community.docker.docker_image: community.docker.docker_image:
name: "{{ image_name }}" name: "{{ image_name }}"
archive_path: "{{ tar_file.path }}" archive_path: ../dist/image.tar
source: local source: local
- name: Compress archive to artifact. - name: Compress archive to artifact.
register: compress_image register: compress_image
community.general.archive: community.general.archive:
path: "{{ tar_file.path }}" path: ../dist/image.tar
dest: "{{ tar_file.path }}.xz" dest: ../dist/image.tar.xz
format: xz format: xz
mode: "0644" mode: "0644"
@@ -34,7 +29,7 @@
amazon.aws.s3_object: amazon.aws.s3_object:
bucket: "{{ image_bucket }}" bucket: "{{ image_bucket }}"
object: "{{ image_key }}" object: "{{ image_key }}"
src: "{{ tar_file.path }}.xz" src: ../dist/image.tar.xz
mode: put mode: put
region: "{{ aws_region }}" region: "{{ aws_region }}"
@@ -87,7 +82,7 @@
state: started state: started
recreate: true recreate: true
restart_policy: unless-stopped restart_policy: unless-stopped
memory: 425m memory: 300m
memory_swap: 900m memory_swap: 900m
ports: [80:80, 2222:2222, 443:443, "22:22"] ports: [80:80, 2222:2222, 443:443, "22:22"]
env: env:
@@ -98,6 +93,8 @@
GITEA__server__SSH_DOMAIN: "{{ full_domain.value }}" GITEA__server__SSH_DOMAIN: "{{ full_domain.value }}"
GITEA__server__DOMAIN: "{{ full_domain.value }}" GITEA__server__DOMAIN: "{{ full_domain.value }}"
GITEA__server__ROOT_URL: "https://{{ full_domain.value }}/" GITEA__server__ROOT_URL: "https://{{ full_domain.value }}/"
GITEA__storage__MINIO_ACCESS_KEY_ID: "{{ minio_access_key }}"
GITEA__storage__MINIO_SECRET_ACCESS_KEY: "{{ minio_secret_key }}"
labels: labels:
docker-volume-backup.stop-during-backup: "true" docker-volume-backup.stop-during-backup: "true"
volumes: volumes:

View File

@@ -3,6 +3,7 @@ ansible-compat==24.10.0
ansible-core==2.18.1 ansible-core==2.18.1
ansible-lint==24.12.2 ansible-lint==24.12.2
attrs==24.3.0 attrs==24.3.0
awscli-local==0.22.0
black==24.10.0 black==24.10.0
boto3==1.35.95 boto3==1.35.95
botocore==1.35.95 botocore==1.35.95
@@ -19,6 +20,7 @@ Jinja2==3.1.5
jmespath==1.0.1 jmespath==1.0.1
jsonschema==4.23.0 jsonschema==4.23.0
jsonschema-specifications==2024.10.1 jsonschema-specifications==2024.10.1
localstack-client==2.7
MarkupSafe==3.0.2 MarkupSafe==3.0.2
mypy-extensions==1.0.0 mypy-extensions==1.0.0
packaging==24.2 packaging==24.2

View File

@@ -1,5 +1,6 @@
#!/bin/sh #!/bin/sh
## Install extras.
rpm --rebuilddb rpm --rebuilddb
amazon-linux-extras install docker ansible2 python3.8 -y amazon-linux-extras install docker ansible2 python3.8 -y
@@ -10,7 +11,7 @@ systemctl start docker
# Set up the correct version of Python (for Ansible). # Set up the correct version of Python (for Ansible).
ln -sf /usr/bin/python3.8 /usr/bin/python3 ln -sf /usr/bin/python3.8 /usr/bin/python3
ln -sf /usr/bin/pip3.8 /usr/bin/pip3 ln -sf /usr/bin/pip3.8 /usr/bin/pip3
pip3 install botocore boto3 requests packaging pip3 install botocore boto3 requests packaging --user ssm-user
python3 -m pip install -U pip python3 -m pip install -U pip
# Add some swap space. # Add some swap space.

View File

@@ -22,15 +22,18 @@ module "vpc" {
map_public_ip_on_launch = true map_public_ip_on_launch = true
enable_dns_hostnames = true enable_dns_hostnames = true
enable_dns_support = true enable_dns_support = true
private_route_table_tags = { TableOf = "Main", TableType = "Public" }
} }
# Only allow HTTP(s) and SSH traffic. Allow full access to internet. # Only allow HTTP(s) and SSH traffic. Allow full access to internet.
resource "aws_security_group" "public_access" { resource "aws_security_group" "public_access" {
vpc_id = module.vpc.vpc_id vpc_id = module.vpc.vpc_id
tags = { GroupOf = "Main", GroupType = "Public" }
} }
resource "aws_vpc_security_group_ingress_rule" "ingress" { resource "aws_vpc_security_group_ingress_rule" "tcp" {
for_each = toset(["80", "443", "22", "2222", "81", "8080", "4321", "1234"]) for_each = toset(["80", "443", "22", "51821"])
security_group_id = aws_security_group.public_access.id security_group_id = aws_security_group.public_access.id
@@ -40,6 +43,17 @@ resource "aws_vpc_security_group_ingress_rule" "ingress" {
cidr_ipv4 = "0.0.0.0/0" cidr_ipv4 = "0.0.0.0/0"
} }
resource "aws_vpc_security_group_ingress_rule" "udp" {
for_each = toset(["51820", "53"])
security_group_id = aws_security_group.public_access.id
from_port = each.value
to_port = each.value
ip_protocol = "udp"
cidr_ipv4 = "0.0.0.0/0"
}
resource "aws_vpc_security_group_egress_rule" "egress" { resource "aws_vpc_security_group_egress_rule" "egress" {
for_each = toset(["-1"]) for_each = toset(["-1"])