Skip to content

Commit

Permalink
Merge pull request #148 from Kyutech-C3/develop
Browse files Browse the repository at this point in the history
ブログ機能のデプロイ
  • Loading branch information
PigeonsHouse authored Dec 4, 2023
2 parents 29e49fd + 3a90a70 commit 007fc99
Show file tree
Hide file tree
Showing 101 changed files with 4,031 additions and 2,135 deletions.
30 changes: 21 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2.1
jobs:
test:
docker:
- image: circleci/python:3.9.7
- image: cimg/python:3.9
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
Expand All @@ -17,33 +17,45 @@ jobs:
S3_BUCKET: toyboxdev
S3_DIR: test_assets
REGION_NAME: ap-northeast-2
ALLOW_ORIGIN_URLS: '*'
MINIO_HOST: 127.0.0.1
MINIO_PORT: 9000
ACCESS_KEY: KW6J6L5FHALG7VKY6UVY
SECRET_ACCESS_KEY: WH3dCfYPn6Czds2PetGJwFv4V4QsuFqGRphBqUPg
APP_TYPE: dev

- image: circleci/postgres:13.3
- image: cimg/postgres:13.3
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_HOST: 127.0.0.1
POSTGRES_DB: toybox

- image: quay.io/minio/minio:latest
environment:
MINIO_ROOT_USER: KW6J6L5FHALG7VKY6UVY
MINIO_ROOT_PASSWORD: WH3dCfYPn6Czds2PetGJwFv4V4QsuFqGRphBqUPg
command: server --console-address ":9001" /data

steps:
- checkout

- restore_cache:
key: toybox-{{ checksum "Pipfile.lock" }}

- run:
name: Install Pipfile dependencies
command: |
pip install pipenv
pipenv install
pipenv sync
- run:
name: make env file
command: echo $ENV_FILE | base64 --decode > .env
name: Run lint
command: pipenv run flake8

- run:
name: Run Test
command: pipenv run pytest

- discord/status:
mentions: '@here'

Expand All @@ -54,4 +66,4 @@ workflows:
version: 2
testing:
jobs:
- test
- test
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ RUN pip install cryptography
COPY ./Pipfile .
COPY ./Pipfile.lock .

RUN pipenv install
RUN pipenv install
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"service": "api",
"workspaceFolder": "/api",
"remoteUser": "root"
}
}
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ services:
- db

volumes:
dbdata:
dbdata:
10 changes: 10 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
TZ=Asia/Tokyo

# App
APP_TYPE=dev

# db
POSTGRES_USER=
POSTGRES_PASSWORD=
Expand All @@ -16,10 +21,15 @@ DISCORD_WEBHOOK_URL=
# URL
HOST_URL=http://localhost:8000
FRONTEND_HOST_URL=http://localhost:3000
ALLOW_ORIGIN_URLS=http://localhost,http://localhost:3000

# wasabi info
S3_BUCKET=
S3_DIR=
REGION_NAME=
ACCESS_KEY=
SECRET_ACCESS_KEY=

# minio info
MINIO_HOST=minio
MINIO_PORT=9000
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
exclude =
alembic/**
extend-ignore = E203,W503
max-line-length = 88
per-file-ignores = */__init__.py:F401,F403,tests/**.py:F401,F811
5 changes: 3 additions & 2 deletions .github/workflows/auto_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
echo "HOST_URL=${{ secrets.HOST_URL }}" >> .env
echo "FRONTEND_HOST_URL=${{ secrets.FRONTEND_HOST_URL }}" >> .env
echo "ALLOW_ORIGIN_URLS=${{ secrets.ALLOW_ORIGIN_URLS }}" >> .env
echo "S3_BUCKET=${{ secrets.S3_BUCKET }}" >> .env
echo "S3_DIR=${{ secrets.S3_DIR }}" >> .env
Expand All @@ -51,7 +52,7 @@ jobs:
- name: deploy
run: |
rsync -av ./ takowasa:/opt/toybox-server
ssh takowasa "cd /opt/toybox-server; docker-compose build; docker-compose down; docker-compose up -d"
ssh takowasa "cd /opt/toybox-server; docker compose build; docker compose down; docker compose up -d"
- name: migrate
run: |
ssh takowasa "cd /opt/toybox-server; docker-compose exec -T api pipenv run alembic upgrade head"
ssh takowasa "cd /opt/toybox-server; docker compose exec -T api pipenv run alembic upgrade head"
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pycqa/isort
rev: "5.12.0"
hooks:
- id: isort
exclude: alembic/
args:
- "--profile=black"
- "-l 88"
- repo: https://github.com/ambv/black
rev: "23.10.1"
hooks:
- id: black
language_version: python3
exclude: alembic/
- repo: https://github.com/pycqa/flake8
rev: "6.1.0"
hooks:
- id: flake8
args:
- "--exclude=alembic/**"
- "--max-line-length=88"
- "--per-file-ignores=*/__init__.py:F401,F403,tests/**.py:F401,F811"
- "--extend-ignore=E203,W503"
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9
8 changes: 6 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"recommendations": [
"ms-python.python",
"streetsidesoftware.code-spell-checker"
"streetsidesoftware.code-spell-checker",
"ms-python.black-formatter",
"ms-python.isort",
"ms-python.flake8",
"usernamehw.errorlens"
]
}
}
50 changes: 47 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
{
"python.formatting.provider": "black",
"[python]": {
"editor.defaultFormatter": null,
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
}
},
"cSpell.words": [
"ASGI",
"autoflush",
"backref",
"boto",
"botocore",
"datname",
"fastapi",
"gltf",
"ilike",
"isort",
"minio",
"msvideo",
"ondelete",
"onupdate",
"passlib",
"pydantic",
"quicktime",
"sessionfinish",
"sessionmaker",
"sketchfab",
"soundcloud",
"sqlalchemy",
"starlette",
"taggings",
"toybox",
"unityroom",
"usefixtures",
"uselist"
],
"files.insertFinalNewline": true,
"black-formatter.args": [
"--exclude=alembic/**"
],
"isort.args": [
"--profile=black",
"--extend-skip-glob=alembic/**",
"-l 88"
],
"flake8.args": [
"--exclude=alembic/**",
"--max-line-length=88",
"--extend-ignore=E203,W503",
"--per-file-ignores=*/__init__.py:F401,F403,tests/**.py:F401,F811"
]
}
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ RUN apk add --no-cache postgresql-libs && \
ENV CRYPTOGRAPHY_DONT_BUILD_RUST=1
RUN pip install --upgrade pip
RUN pip install pipenv
RUN pip install cryptography

COPY ./Pipfile .
COPY ./Pipfile.lock .

RUN pipenv install
RUN pipenv sync
13 changes: 10 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@ name = "pypi"
[packages]
fastapi = "*"
uvicorn = {extras = ["standard"], version = "*"}
sqlalchemy = "*"
sqlalchemy = "==1.4.41"
psycopg2 = "*"
passlib = {extras = ["bcrypt"], version = "*"}
python-jose = {extras = ["cryptography"], version = "*"}
python-multipart = "*"
pytest = "*"
requests = "*"
pylint = "*"
pydantic = {extras = ["email"], version = "*"}
sqlalchemy-utils = "*"
pydantic = {extras = ["email"], version = "==1.*"}
sqlalchemy-utils = "==0.38.3"
markdown = "*"
alembic = "*"
aiofiles = "*"
certifi = "*"
boto3 = "*"
pillow = "*"
httpx = "*"
cryptography = "*"
isort = "*"
black = "*"
flake8 = "*"
pre-commit = "*"

[dev-packages]

Expand Down
Loading

0 comments on commit 007fc99

Please sign in to comment.