diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c79d3c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.env* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eedfcbc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM redis:alpine AS redis-server +ADD start-redis-server.sh /usr/bin/ +RUN chmod +x /usr/bin/start-redis-server.sh +CMD ["start-redis-server.sh"] + +FROM ghcr.io/mastodon/mastodon:edge +ENV PORT 8080 +ENV BIND 0.0.0.0 +ENTRYPOINT [] diff --git a/README.md b/README.md index e69de29..ae46663 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,26 @@ +# mastodon + +- https://github.com/mastodon/mastodon +- https://github.com/mastodon/mastodon/pkgs/container/mastodon +- https://hub.docker.com/r/tootsuite/mastodon + +## update + +```sh +$ docker compose pull +$ docker compose build +$ docker compose run --rm mastodon rails db:migrate +$ docker compose up -d +``` + +## db:encryption + +```sh +$ docker compose run --rm mastodon rails db:encryption:init + +$ vim .env.production +ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=xxx +ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=xxx +ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=xxx +``` + diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..f2a26f0 --- /dev/null +++ b/compose.yml @@ -0,0 +1,68 @@ +services: + ms_db: + restart: always + image: postgres:14-alpine + shm_size: 256mb + networks: + - internal_network + healthcheck: + test: ['CMD', 'pg_isready', '-U', 'postgres'] + volumes: + - ./postgres14:/var/lib/postgresql/data + environment: + - POSTGRES_HOST_AUTH_METHOD=trust + - POSTGRES_PASSWORD=xxx + - PGPORT=5432 + + ms_redis: + restart: always + image: redis:7-alpine + networks: + - internal_network + healthcheck: + test: ['CMD', 'redis-cli', 'ping'] + volumes: + - ./redis:/data + + mastodon: + build: . + image: ghcr.io/mastodon/mastodon:edge + restart: always + env_file: .env.production + command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000" + networks: + - external_network + - internal_network + healthcheck: + # prettier-ignore + test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:3000/health || exit 1'] + ports: + - '0.0.0.0:3000:3000' + depends_on: + - ms_db + - ms_redis + # - es + volumes: + - ./public/system:/mastodon/public/system + + sidekiq: + build: . + image: ghcr.io/mastodon/mastodon:edge + restart: always + env_file: .env.production + command: bundle exec sidekiq + depends_on: + - ms_db + - ms_redis + networks: + - external_network + - internal_network + volumes: + - ./public/system:/mastodon/public/system + healthcheck: + test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"] + +networks: + external_network: + internal_network: + internal: true