Compare commits

...

2 Commits

Author SHA1 Message Date
be97df6331 update gitignore
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2023-04-22 15:17:54 +01:00
87e53b42a6 merged CI changes 2023-04-22 15:16:41 +01:00
25 changed files with 90 additions and 26 deletions

44
.woodpecker.yml Normal file
View File

@ -0,0 +1,44 @@
pipeline:
buildweb:
group: build
image: node
when:
path: "web/*"
environment:
- VITE_API_URL=https://api.treadl.com
- VITE_IMAGINARY_URL=https://images.treadl.com
- VITE_SOURCE_REPO_URL=https://git.wilw.dev/wilw/treadl
- VITE_PATREON_URL=https://www.patreon.com/treadl
- VITE_KOFI_URL=https://ko-fi.com/wilw88
- VITE_CONTACT_EMAIL=hello@treadl.com
- VITE_APP_NAME=Treadl
commands:
- cd web
- yarn install
- yarn build
buildapi:
group: build
image: woodpeckerci/plugin-docker-buildx
secrets: [docker_username, docker_password]
when:
path: "api/*"
settings:
repo: wilw/treadl-api
dockerfile: api/Dockerfile
context: api
deployweb:
image: alpine
secrets: [ LINODE_ACCESS_KEY, LINODE_SECRET_ACCESS_KEY, BUNNY_KEY ]
when:
path: "web/*"
commands:
- cd web
- apk update
- apk add s3cmd curl
- s3cmd --configure --access_key=$LINODE_ACCESS_KEY --secret_key=$LINODE_SECRET_ACCESS_KEY --host=https://eu-central-1.linodeobjects.com --host-bucket="%(bucket)s.eu-central-1.linodeobjects.com" --dump-config > /root/.s3cfg
- s3cmd -c /root/.s3cfg sync --no-mime-magic --guess-mime-type dist/* s3://treadl.com
- 'curl -X POST -H "AccessKey: $BUNNY_KEY" https://api.bunny.net/pullzone/782753/purgeCache'
branches: main

3
api/.gitignore vendored
View File

@ -6,4 +6,5 @@ __pycache__/
.chalice/venv/
config-prod.yml
envfile
firebase.json
firebase.json
.DS_Store

View File

@ -13,6 +13,7 @@ RUN poetry export --without-hashes -f requirements.txt | pip install -r /dev/std
# Add remaining files
COPY app.py .
COPY chalicelib/ ./chalicelib
COPY api/ .
COPY util/ .
CMD ["gunicorn" , "-b", "0.0.0.0:8000", "app:app"]

View File

@ -1,7 +1,7 @@
import datetime, jwt, bcrypt, re, os
from bson.objectid import ObjectId
from chalicelib.util import database, mail, util
from chalicelib.api import uploads
from util import database, mail, util
from api import uploads
jwt_secret = os.environ['JWT_SECRET']
MIN_PASSWORD_LENGTH = 8

View File

@ -1,6 +1,6 @@
import os, re
from chalicelib.util import database, util
from chalicelib.api import uploads
from util import database, util
from api import uploads
DOMAIN = os.environ.get('APP_DOMAIN')

View File

@ -1,8 +1,8 @@
import datetime, re, os
import pymongo
from bson.objectid import ObjectId
from chalicelib.util import database, util, mail, push
from chalicelib.api import uploads
from util import database, util, mail, push
from api import uploads
APP_NAME = os.environ.get('APP_NAME')
APP_URL = os.environ.get('APP_URL')

View File

@ -1,8 +1,8 @@
import re, datetime, os
import pymongo
from bson.objectid import ObjectId
from chalicelib.util import database, util, mail
from chalicelib.api import uploads, groups
from util import database, util, mail
from api import uploads, groups
APP_NAME = os.environ.get('APP_NAME')
APP_URL = os.environ.get('APP_URL')

View File

@ -1,8 +1,8 @@
import datetime, base64, os
from bson.objectid import ObjectId
import requests
from chalicelib.util import database, wif, util, mail
from chalicelib.api import uploads
from util import database, wif, util, mail
from api import uploads
APP_NAME = os.environ.get('APP_NAME')

View File

@ -1,7 +1,7 @@
import datetime, re
from bson.objectid import ObjectId
from chalicelib.util import database, wif, util
from chalicelib.api import uploads
from util import database, wif, util
from api import uploads
default_pattern = {
'warp': {

View File

@ -1,8 +1,8 @@
import re, datetime
import pymongo
from bson.objectid import ObjectId
from chalicelib.util import database, util, mail
from chalicelib.api import uploads, groups
from util import database, util, mail
from api import uploads, groups
def get_users(user):
db = database.get_db()

View File

@ -1,7 +1,7 @@
import re, random
import pymongo
from chalicelib.util import database, util
from chalicelib.api import uploads
from util import database, util
from api import uploads
def all(user, params):
if not params or 'query' not in params: raise util.errors.BadRequest('Username parameter needed')

View File

@ -4,7 +4,7 @@ from bson.objectid import ObjectId
import boto3
from botocore.client import Config
import blurhash
from chalicelib.util import database
from util import database
def sanitise_filename(s):
bad_chars = re.compile('[^a-zA-Z0-9_.]')

View File

@ -1,7 +1,7 @@
import datetime
from bson.objectid import ObjectId
from chalicelib.util import database, util
from chalicelib.api import uploads
from util import database, util
from api import uploads
def me(user):
return {

View File

@ -5,8 +5,8 @@ from flask_cors import CORS
import werkzeug
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration
from chalicelib.util import util
from chalicelib.api import accounts, users, projects, objects, uploads, groups, search, invitations, root, activitypub
from util import util
from api import accounts, users, projects, objects, uploads, groups, search, invitations, root, activitypub
app = Flask(__name__)
CORS(app)

View File

@ -6,7 +6,7 @@ export MAILGUN_KEY=""
export MONGO_URL="mongodb://localhost"
export MONGO_DATABASE="treadl"
export JWT_SECRET="devsecret"
export GOOGLE_APPLICATION_CREDENTIALS="chalicelib/firebase.json"
export GOOGLE_APPLICATION_CREDENTIALS="firebase.json"
export AWS_S3_ENDPOINT="https://eu-central-1.linodeobjects.com/"
export AWS_S3_BUCKET="treadl"
export AWS_ACCESS_KEY_ID=""

View File

@ -5,8 +5,8 @@ from flask_limiter.util import get_remote_address
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from bson.objectid import ObjectId
from chalicelib.api import accounts
from chalicelib.util import util
from api import accounts
from util import util
errors = werkzeug.exceptions

18
web/bucket-policy.json Normal file
View File

@ -0,0 +1,18 @@
{
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": [
"*"
]
},
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3::treadl.com/*"
]
}
]
}