Compare commits
3 Commits
497a989b81
...
10b93da163
| Author | SHA1 | Date | |
|---|---|---|---|
| 10b93da163 | |||
| b9d51d52b1 | |||
| fa62381df1 |
@@ -12,17 +12,16 @@ services:
|
||||
|
||||
gitea:
|
||||
container_name: codebase-dev-gitea
|
||||
build: gitea
|
||||
build:
|
||||
context: gitea
|
||||
dockerfile: Dockerfile.dev
|
||||
volumes:
|
||||
- ./gitea/boot:/var/lib/gitea
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- 80:80
|
||||
- 443:443
|
||||
- 2222:2222
|
||||
environment:
|
||||
GITEA_APP_INI: /etc/gitea/dev.app.ini
|
||||
|
||||
# runner:
|
||||
# container_name: codebase-dev-runner
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
FROM gitea/gitea:latest-rootless
|
||||
FROM gitea/gitea:latest
|
||||
|
||||
ADD --chown=git:git config /etc/gitea
|
||||
ADD --chown=git:git custom /etc/gitea-custom
|
||||
ENV GITEA_CUSTOM /etc/gitea-custom
|
||||
RUN apk add aws-cli xz
|
||||
|
||||
ADD --chown=git:git custom /data/gitea
|
||||
ADD --chown=git:git entrypoint.sh /home/entrypoint.sh
|
||||
|
||||
ADD --chown=git:git scripts /home/scripts
|
||||
RUN chmod +x /home/scripts/*
|
||||
|
||||
ADD --chown=git:git crontab.txt /home/crontab.txt
|
||||
RUN /usr/bin/crontab /home/crontab.txt
|
||||
|
||||
ENTRYPOINT [ "/home/entrypoint.sh" ]
|
||||
CMD [ "/usr/bin/s6-svscan", "/etc/s6" ]
|
||||
18
gitea/Dockerfile.dev
Normal file
18
gitea/Dockerfile.dev
Normal file
@@ -0,0 +1,18 @@
|
||||
FROM gitea/gitea:latest
|
||||
|
||||
RUN apk add aws-cli xz
|
||||
|
||||
ADD --chown=git:git custom /data/gitea
|
||||
ADD --chown=git:git entrypoint.sh /home/entrypoint.sh
|
||||
|
||||
ADD --chown=git:git scripts /home/scripts
|
||||
RUN chmod +x /home/scripts/*
|
||||
|
||||
ADD --chown=git:git crontab.txt /home/crontab.txt
|
||||
RUN /usr/bin/crontab /home/crontab.txt
|
||||
|
||||
RUN rm /data/gitea/conf/app.ini
|
||||
RUN mv /data/gitea/conf/dev.app.ini /data/gitea/conf/app.ini
|
||||
|
||||
ENTRYPOINT [ "/home/entrypoint.sh" ]
|
||||
CMD [ "/usr/bin/s6-svscan", "/etc/s6" ]
|
||||
@@ -1 +0,0 @@
|
||||
0 0 * * * ./backup >> /backup.log 2>&1
|
||||
1
gitea/crontab.txt
Normal file
1
gitea/crontab.txt
Normal file
@@ -0,0 +1 @@
|
||||
0 0 * * * /home/scripts/push.sh >> /home/cron.log
|
||||
12
gitea/entrypoint.sh
Executable file
12
gitea/entrypoint.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Get S3 data.
|
||||
echo "Pulling data..."
|
||||
./home/scripts/pull.sh
|
||||
echo "Data pulled!"
|
||||
|
||||
# Run crontab.
|
||||
/usr/sbin/crond -f -l 8 &
|
||||
|
||||
# shellcheck disable=SC2068
|
||||
exec /usr/bin/entrypoint $@
|
||||
10
gitea/scripts/pull.sh
Normal file
10
gitea/scripts/pull.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# Pull achived data.
|
||||
aws s3 cp "$BOOT_URI" /home/archive.tar.xz
|
||||
|
||||
# Extracted Gitea data.
|
||||
mkdir -p /var/lib/gitea
|
||||
tar -xvf /home/archive.tar.xz -C /var/lib/gitea
|
||||
23
gitea/scripts/push.sh
Normal file
23
gitea/scripts/push.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
GITEA_PROCESS="$(pgrep gitea)"
|
||||
|
||||
# Stop Gitea.
|
||||
echo "Stopped Gitea..."
|
||||
kill -STOP "$GITEA_PROCESS"
|
||||
|
||||
# Archive Gitea data.
|
||||
echo "Archiving..."
|
||||
cd /var/lib/gitea
|
||||
tar cfJ ../archive.tar.xz .
|
||||
cd ..
|
||||
|
||||
# Upload to S3.
|
||||
echo "Uploading..."
|
||||
aws s3 cp archive.tar.xz "$BOOT_URI"
|
||||
|
||||
# Restart Gitea.
|
||||
kill -CONT "$GITEA_PROCESS"
|
||||
echo "Restarted Gitea!"
|
||||
@@ -62,12 +62,11 @@
|
||||
GITEA__security__INTERNAL_TOKEN: "{{ internal_secret }}"
|
||||
GITEA__server__LFS_JWT_SECRET: "{{ lfs_secret }}"
|
||||
GITEA__oauth2__JWT_SECRET: "{{ jwt_secret }}"
|
||||
AWS_REGION: "{{ gitea_boot.value.region }}"
|
||||
AWS_ACCESS_KEY_ID: "{{ gitea_boot.value.id }}"
|
||||
AWS_SECRET_ACCESS_KEY: "{{ gitea_boot.value.secret }}"
|
||||
BOOT_URI: "s3://{{ boot_bucket }}/{{ boot_key }}"
|
||||
volumes:
|
||||
- /root/boot:/var/lib/gitea
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
|
||||
# docker stop server
|
||||
# sudo tar cfJ /root/archive.tar.xz -P /root/boot
|
||||
# sudo aws s3 cp /root/archive.tar.xz s3://acer-saccharum/codebase/gitea/boot
|
||||
# docker start server
|
||||
|
||||
@@ -23,5 +23,3 @@
|
||||
ansible.builtin.unarchive:
|
||||
src: "{{ file.path }}"
|
||||
dest: ../../gitea
|
||||
|
||||
# monster mango no sugar
|
||||
|
||||
41
requirements.txt
Normal file
41
requirements.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
ansible==11.1.0
|
||||
ansible-compat==24.10.0
|
||||
ansible-core==2.18.1
|
||||
ansible-lint==24.12.2
|
||||
attrs==24.3.0
|
||||
black==24.10.0
|
||||
boto3==1.35.95
|
||||
botocore==1.35.95
|
||||
bracex==2.5.post1
|
||||
certifi==2024.12.14
|
||||
cffi==1.17.1
|
||||
charset-normalizer==3.4.1
|
||||
click==8.1.8
|
||||
cryptography==44.0.0
|
||||
filelock==3.16.1
|
||||
idna==3.10
|
||||
importlib_metadata==8.5.0
|
||||
Jinja2==3.1.5
|
||||
jmespath==1.0.1
|
||||
jsonschema==4.23.0
|
||||
jsonschema-specifications==2024.10.1
|
||||
MarkupSafe==3.0.2
|
||||
mypy-extensions==1.0.0
|
||||
packaging==24.2
|
||||
pathspec==0.12.1
|
||||
platformdirs==4.3.6
|
||||
pycparser==2.22
|
||||
python-dateutil==2.9.0.post0
|
||||
PyYAML==6.0.2
|
||||
referencing==0.35.1
|
||||
requests==2.32.3
|
||||
resolvelib==1.0.1
|
||||
rpds-py==0.22.3
|
||||
ruamel.yaml==0.18.10
|
||||
s3transfer==0.10.4
|
||||
six==1.17.0
|
||||
subprocess-tee==0.4.2
|
||||
urllib3==2.3.0
|
||||
wcmatch==10.0
|
||||
yamllint==1.35.1
|
||||
zipp==3.21.0
|
||||
@@ -2,10 +2,18 @@
|
||||
|
||||
amazon-linux-extras install docker ansible2 python3.8 -y
|
||||
|
||||
# Make Docker work.
|
||||
systemctl enable docker
|
||||
systemctl start docker
|
||||
|
||||
usermod -a -G docker ssm-user
|
||||
|
||||
# Set up the correct version of Python (for Ansible).
|
||||
ln -sf /usr/bin/python3.8 /usr/bin/python3
|
||||
ln -sf /usr/bin/pip3.8 /usr/bin/pip3
|
||||
pip3 install botocore boto3 requests
|
||||
pip3 install botocore boto3 requests
|
||||
|
||||
# Add some swap space.
|
||||
sudo dd if=/dev/zero of=/swapfile bs=128M count=8
|
||||
sudo chmod 600 /swapfile
|
||||
sudo mkswap /swapfile
|
||||
sudo swapon /swapfile
|
||||
Reference in New Issue
Block a user