在vps已有毛象的基础上安装bookwyrm

和官方教程一模一样,除了.envdocker-compose.yml:

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY=OhGezuz2021

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG=false

USE_HTTPS=true

DOMAIN="你的域名"
EMAIL=你的站长邮箱

# Used for deciding which editions to prefer
DEFAULT_LANGUAGE="English"

## Leave unset to allow all hosts
# ALLOWED_HOSTS="localhost,127.0.0.1,[::1]"

MEDIA_ROOT=images/

OL_URL=https://openlibrary.org

## Database backend to use.
## Default is postgres, sqlite is for dev quickstart only (NOT production!!!)
BOOKWYRM_DATABASE_BACKEND=postgres

MEDIA_ROOT=images/

POSTGRES_PORT=5432
POSTGRES_PASSWORD="你的Postgres密码"
POSTGRES_USER=fedireads
POSTGRES_DB=fedireads
POSTGRES_HOST=db

# Redis activity stream manager
MAX_STREAM_LENGTH=200
REDIS_ACTIVITY_HOST=redis_activity
REDIS_ACTIVITY_PORT=6380
REDIS_ACTIVITY_PASSWORD="你的redis密码"

# Redis as celery broker
REDIS_BROKER_PORT=6379
REDIS_BROKER_PASSWORD=你的redis密码
#CELERY_BROKER=redis://:${REDIS_BROKER_PASSWORD}@redis_broker:${REDIS_BROKER_PORT}/0
#CELERY_RESULT_BACKEND=redis://:${REDIS_BROKER_PASSWORD}@redis_broker:${REDIS_BROKER_PORT}/0

FLOWER_PORT=8888
FLOWER_USER=你的花花用户名
FLOWER_PASSWORD="你的花花密码"

EMAIL_HOST="smtp.eu.mailgun.org"
EMAIL_PORT=587
EMAIL_HOST_USER=mail@域名.com
EMAIL_HOST_PASSWORD=你的这个mail@域名 的密码
EMAIL_USE_TLS=true
EMAIL_USE_SSL=false

# Set this to true when initializing certbot for domain, false when not
CERTBOT_INIT=false

# Thumbnails Generation
ENABLE_THUMBNAIL_GENERATION=false

# S3 configuration
USE_S3=false
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=

# Commented are example values if you use a non-AWS, S3-compatible service
# AWS S3 should work with only AWS_STORAGE_BUCKET_NAME and AWS_S3_REGION_NAME
# non-AWS S3-compatible services will need AWS_STORAGE_BUCKET_NAME,
# along with both AWS_S3_CUSTOM_DOMAIN and AWS_S3_ENDPOINT_URL

# AWS_STORAGE_BUCKET_NAME=        # "example-bucket-name"
# AWS_S3_CUSTOM_DOMAIN=None       # "example-bucket-name.s3.fr-par.scw.cloud"
# AWS_S3_REGION_NAME=None         # "fr-par"
# AWS_S3_ENDPOINT_URL=None        # "https://s3.fr-par.scw.cloud"


# Preview image generation can be computing and storage intensive
# ENABLE_PREVIEW_IMAGES=True

# Specify RGB tuple or RGB hex strings,
# or use_dominant_color_light / use_dominant_color_dark
PREVIEW_BG_COLOR=use_dominant_color_light
# Change to #FFF if you use use_dominant_color_dark
PREVIEW_TEXT_COLOR="#363636"
PREVIEW_IMG_WIDTH=1200
PREVIEW_IMG_HEIGHT=630
PREVIEW_DEFAULT_COVER_COLOR="#002549"

docker-compose.yml

version: '3'

services:
  nginx:
    image: nginx:latest
    ports:
      - 8001:8001
    depends_on:
      - web
    networks:
      - main
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - static_volume:/app/static
      - media_volume:/app/images
  db:
    build: postgres-docker
    env_file: .env
    entrypoint: /bookwyrm-entrypoint.sh
    command: cron postgres
    volumes:
      - pgdata:/var/lib/postgresql/data
      - backups:/backups
    networks:
      - main
    ports:
      - 5433:5432
  web:
    build: .
    env_file: .env
    command: gunicorn bookwyrm.wsgi:application --bind 0.0.0.0:8000
    volumes:
      - .:/app
      - static_volume:/app/static
      - media_volume:/app/images
    depends_on:
      - db
      - celery_worker
      - redis_activity
    networks:
      - main
    ports:
      - 8000:8000
  redis_activity:
    image: redis
    command: redis-server --requirepass ${REDIS_ACTIVITY_PASSWORD} --appendonly yes --port ${REDIS_ACTIVITY_PORT}
    volumes:
      - ./redis.conf:/etc/redis/redis.conf
      - redis_activity_data:/data
    env_file: .env
    networks:
      - main
    restart: on-failure
  redis_broker:
    image: redis
    command: redis-server --requirepass ${REDIS_BROKER_PASSWORD} --appendonly yes --port ${REDIS_BROKER_PORT}
    volumes:
      - ./redis.conf:/etc/redis/redis.conf
      - redis_broker_data:/data
    env_file: .env
    ports:
      - 6380:6379
    networks:
      - main
    restart: on-failure
  celery_worker:
    env_file: .env
    build: .
    networks:
      - main
    command: celery -A celerywyrm worker -l info
    volumes:
      - .:/app
      - static_volume:/app/static
      - media_volume:/app/images
    depends_on:
      - db
      - redis_broker
    restart: on-failure
  flower:
    build: .
    command: flower -A celerywyrm
    env_file: .env
    volumes:
      - .:/app
    networks:
      - main
    depends_on:
      - db
      - redis_broker
    restart: on-failure
    ports:
      - 8888:8888
volumes:
  pgdata:
  backups:
  static_volume:
  media_volume:
  redis_broker_data:
  redis_activity_data:
networks:
  main:

以及nginx的reverse proxy:

server {
    server_name 域名;

    listen [::]:80;
    listen 80;
    add_header Strict-Transport-Security "max-age=31536000;includeSubDomains" always;
    rewrite ^ https://$server_name$request_uri;
    location / { return 301 https://$host$request_uri; }
}

# SSL code
ssl_certificate /etc/letsencrypt/live/域名/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/域名/privkey.pem;

server {
    listen [::]:443 ssl http2;
    listen 443 ssl http2;

    server_name 域名;
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    location / {
        proxy_pass http://localhost:8000;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
    }

    location /images/ {
        proxy_pass http://localhost:8001;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
    }

    location /static/ {
        proxy_pass http://localhost:8001;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
    }
}

S3 设置

# S3 configuration                                                                                                      USE_S3=true                                                                                                             AWS_ACCESS_KEY_ID=你的aws的ID
AWS_SECRET_ACCESS_KEY=你的aws的id的密码                                                                                                                                                                                                                                                                               AWS_STORAGE_BUCKET_NAME="桶名字"
AWS_S3_CUSTOM_DOMAIN="桶名字.桶地区.桶服务商.com"       # "example-bucket-name.s3.fr-par.scw.cloud"         

AWS_S3_REGION_NAME="地区"           # "fr-par"                                                                       AWS_S3_ENDPOINT_URL="https://s3.fr-par.scw.cloud"  

(S3部分指路万能的皮皮站长教程

升级:

git pull

docker-compose build

docker-compose exec web python manage.py migrate

docker-compose exec web python manage.py collectstatic --no-input

docker-compose up -d

docker system prune -a