Merge pull request 'Test environment revision and dev environment implementation' (#33) from 31-revise-local-test-suite-and-create-local-dev-container into dev

Reviewed-on: https://codeberg.org/yeentown/barkey/pulls/33

Closes #31
This commit is contained in:
zima 2024-12-23 23:49:22 +00:00
commit db7f94dd69
7 changed files with 104 additions and 15 deletions

View file

@ -6,7 +6,7 @@
#───┘ URL └─────────────────────────────────────────────────────
# Final accessible URL seen by a user.
url: http://misskey.local
url: http://127.0.0.1:3000
# ONCE YOU HAVE STARTED THE INSTANCE, DO NOT CHANGE THE
# URL SETTINGS AFTER THAT!
@ -221,9 +221,10 @@ checkActivityPubGetSignature: false
# For security reasons, uploading attachments from the intranet is prohibited,
# but exceptions can be made from the following settings. Default value is "undefined".
# Read changelog to learn more (Improvements of 12.90.0 (2021/09/04)).
#allowedPrivateNetworks: [
# '127.0.0.1/32'
#]
allowedPrivateNetworks: [
'127.0.0.1/32',
'192.168.65.0/24'
]
#customMOTD: ['Hello World', 'The sharks rule all', 'Shonks']

51
compose.local-dev.yml Normal file
View file

@ -0,0 +1,51 @@
# このconfigは、 dockerでMisskey本体を起動せず、 redisとpostgresql などだけを起動します
name: barkey-devcontainer
services:
redis:
restart: always
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- ./redis:/data
healthcheck:
test: "redis-cli ping"
interval: 5s
retries: 20
postgres:
restart: always
image: postgres:15-alpine
ports:
- "5432:5432"
env_file:
- .config/docker.env
volumes:
- ./db:/var/lib/postgresql/data
healthcheck:
test: "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"
interval: 5s
retries: 20
web:
restart: always
image: node:iron
ports:
- 3000:3000
- 5173:5173
working_dir: /host
volumes:
- ./:/host
command: sleep infinity
# meilisearch:
# restart: always
# image: getmeili/meilisearch:v1.3.4
# environment:
# - MEILI_NO_ANALYTICS=true
# - MEILI_ENV=production
# env_file:
# - .config/meilisearch.env
# volumes:
# - ./meili_data:/meili_data

View file

@ -1,13 +1,11 @@
# このconfigは、 dockerでMisskey本体を起動せず、 redisとpostgresql などだけを起動します
name: barkey-test
services:
redis:
restart: always
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- ./redis:/data
healthcheck:
test: "redis-cli ping"
interval: 5s
@ -20,8 +18,6 @@ services:
- "5432:5432"
env_file:
- .config/docker.env
volumes:
- ./db:/var/lib/postgresql/data
healthcheck:
test: "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"
interval: 5s
@ -32,6 +28,7 @@ services:
image: node:iron
ports:
- 3000:3000
working_dir: /host
volumes:
- ./:/host
command: sleep infinity

View file

@ -32,7 +32,7 @@ const devConfig: UserConfig = {
publicDir: '../assets',
base: './',
server: {
host: 'localhost',
host: '0.0.0.0',
port: 5173,
proxy: {
'/api': {

42
setup-dev.sh Executable file
View file

@ -0,0 +1,42 @@
#!/bin/bash
read -p "Reset databases? [y/N] " cleardb
case $cleardb in
[Yy] )
echo "Clearning postgres..."
rm -rf ./db
sleep 1
echo "Clearing redis..."
rm -rf ./redis
sleep 1
;;
* )
;;
esac
cp .config/ci.yml .config/default.yml
cp .config/ci.yml .config/test.yml
cp .config/docker_ci.env .config/docker.env
cp compose.local-dev.yml compose.yml
echo Creating environment...
docker compose up -d
docker compose exec web apt-get update
docker compose exec web apt-get install -y bash
echo Installing dependencies...
docker compose exec web apt-get install -y git wget curl build-essential python3 ffmpeg
docker compose exec web corepack enable
docker compose exec web corepack prepare pnpm@latest --activate
docker compose exec web git submodule update --init
docker compose exec web pnpm install --frozen-lockfile
echo Environment is ready.
echo 5173 for dev, and 3000 for prod.
echo Do not forget to \`pnpm migrate\` before your first launch!
docker compose exec web bash
echo Stopping containers...
docker compose stop
rm -f compose.yml

View file

@ -1,9 +1,8 @@
#!/bin/bash
echo "This script will destroy the following local directories:"
echo "During testing, your local postgres and redis databases will not be touched."
echo "This script will remove the build directories in the following locations:"
echo " ./built"
echo " ./db"
echo " ./redis"
echo
echo "Do you want to continue? [Y/n]"
read -p "> " confirmation
@ -29,7 +28,7 @@ docker compose rm
echo Removing any preexisting builds and databases.
echo This may take a few moments...
rm -rf ./built ./db ./redis
rm -rf ./built
echo Creating environment
docker compose up -d

View file

@ -4,7 +4,6 @@
set -e
cd /host/
apt-get update && apt-get install -y git wget curl build-essential python3 ffmpeg
corepack enable
corepack prepare pnpm@latest --activate