Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
a217464a7f
|
|||
|
ea9e9556f4
|
|||
|
0d45b21bce
|
|||
|
3af5f8ff61
|
|||
|
bf939790c0
|
|||
|
6a0b836c0f
|
|||
|
16c2c8e386
|
|||
|
aeeeebd3da
|
|||
|
2134eed508
|
|||
|
0ebb992280
|
|||
|
6758d1f0bf
|
|||
|
3a0225e635
|
|||
|
4258b0a7af
|
@@ -7,7 +7,7 @@ on:
|
|||||||
env:
|
env:
|
||||||
ENDPOINT: services-3
|
ENDPOINT: services-3
|
||||||
STACK: mastodon
|
STACK: mastodon
|
||||||
IMAGE: com.devsoap/mastobot
|
IMAGE: john/mastobot
|
||||||
TAG: ${{ gitea.ref_name }}
|
TAG: ${{ gitea.ref_name }}
|
||||||
CACHE_NAME: cache-python-dependencies-mastobot
|
CACHE_NAME: cache-python-dependencies-mastobot
|
||||||
RUNNER_TOOL_CACHE: /toolcache
|
RUNNER_TOOL_CACHE: /toolcache
|
||||||
@@ -15,30 +15,32 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
build-docker-image:
|
build-docker-image:
|
||||||
runs-on: python
|
runs-on: node20
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-20.04
|
image: catthehacker/ubuntu:act-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Docker file
|
- name: Checkout Docker file
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ssh-key: ${{ secrets.SSH_DEVSOAP_PRIVATE_KEY }}
|
ssh-key: ${{ secrets.SSH_JOHN_PRIVATE_KEY }}
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to Devsoap Container Registry
|
- name: Login to Devsoap Container Registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.DOCKER_REGISTRY }}
|
registry: ${{ secrets.DOCKER_REGISTRY }}
|
||||||
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
||||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||||
|
scope: ${{secrets.DOCKER_REGISTRY}}/${{env.IMAGE}}@push
|
||||||
|
logout: true
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
push: true
|
push: true
|
||||||
build-args: |
|
build-args: |
|
||||||
VERSION=${{env.TAG}}
|
version=${{env.TAG}}
|
||||||
tags: |
|
tags: |
|
||||||
${{secrets.DOCKER_REGISTRY}}/${{env.IMAGE}}:${{env.TAG}}
|
${{secrets.DOCKER_REGISTRY}}/${{env.IMAGE}}:${{env.TAG}}
|
||||||
${{secrets.DOCKER_REGISTRY}}/${{env.IMAGE}}:latest
|
${{secrets.DOCKER_REGISTRY}}/${{env.IMAGE}}:latest
|
||||||
@@ -46,11 +48,10 @@ jobs:
|
|||||||
deploy-to-production:
|
deploy-to-production:
|
||||||
if: ${{ always() && needs.build-docker-image.result == 'success' }}
|
if: ${{ always() && needs.build-docker-image.result == 'success' }}
|
||||||
needs: build-docker-image
|
needs: build-docker-image
|
||||||
runs-on: python
|
runs-on: node20
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout infrastructure config
|
- name: Checkout infrastructure config
|
||||||
run: |
|
run: |
|
||||||
echo "Cloning repository ${{ env.REPOSITORY_URL }}"
|
|
||||||
git clone -v --depth=1 ${{ env.REPOSITORY_URL }} infra
|
git clone -v --depth=1 ${{ env.REPOSITORY_URL }} infra
|
||||||
env:
|
env:
|
||||||
REPOSITORY_URL: ${{ env.GIT_REPO_USER }}@${{ env.GIT_REPO_INTERNAL }}:${{ env.DEVSOAP_INFRA_GIT_REPO }}
|
REPOSITORY_URL: ${{ env.GIT_REPO_USER }}@${{ env.GIT_REPO_INTERNAL }}:${{ env.DEVSOAP_INFRA_GIT_REPO }}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ COPY ./app /code/app
|
|||||||
COPY ./log_config.yml /code/log_config.yml
|
COPY ./log_config.yml /code/log_config.yml
|
||||||
ARG version
|
ARG version
|
||||||
ENV VERSION=${version}
|
ENV VERSION=${version}
|
||||||
|
RUN echo "Build Version: $VERSION"
|
||||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||||
CMD wget --spider --quiet --tries=1 --timeout=5 --server-response http://127.0.0.1:8000/health 2>&1 | grep "200 OK" > /dev/null
|
CMD wget --spider --quiet --tries=1 --timeout=5 --server-response http://127.0.0.1:8000/health 2>&1 | grep "200 OK" > /dev/null
|
||||||
CMD ["uvicorn", "main:app", "--app-dir", "app", "--log-config", "log_config.yml", "--host","0.0.0.0", "--port", "8000"]
|
CMD ["uvicorn", "main:app", "--app-dir", "app", "--log-config", "log_config.yml", "--host","0.0.0.0", "--port", "8000"]
|
||||||
@@ -18,10 +18,15 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
@router.get("/generate", summary="Embeddable Mastodon Feed")
|
@router.get("/generate", summary="Embeddable Mastodon Feed")
|
||||||
async def generate_static_page(settings: Annotated[Settings, Depends(get_settings)]):
|
async def generate_static_page(settings: Annotated[Settings, Depends(get_settings)]):
|
||||||
mastodon_token = settings.feeds['embed']['token']
|
|
||||||
|
mastodon_server = settings.mastodon_server
|
||||||
|
mastodon_aid = settings.feeds['embed']['account_id']
|
||||||
|
mastodon_token = str(settings.feeds['embed']['token'])
|
||||||
|
mastodon_get_statuses_url=f'{mastodon_server}/api/v1/accounts/{mastodon_aid}/statuses'
|
||||||
|
|
||||||
s3_bucket = settings.feeds['embed']['s3_bucket']
|
s3_bucket = settings.feeds['embed']['s3_bucket']
|
||||||
s3_filename = settings.feeds['embed']['s3_key']
|
s3_filename = settings.feeds['embed']['s3_key']
|
||||||
mastodon_get_statuses_url=settings.feeds['embed']['url']
|
|
||||||
try:
|
try:
|
||||||
latest_statuses = load_latest_statuses(mastodon_get_statuses_url, mastodon_token, 20)
|
latest_statuses = load_latest_statuses(mastodon_get_statuses_url, mastodon_token, 20)
|
||||||
latest_statuses = [status for status in latest_statuses if status['in_reply_to_id'] == None]
|
latest_statuses = [status for status in latest_statuses if status['in_reply_to_id'] == None]
|
||||||
|
|||||||
Reference in New Issue
Block a user