mozilla-services / syncserver

Run-Your-Own Firefox Sync Server
Mozilla Public License 2.0
1.87k stars 145 forks source link

Add support for PostgreSQL to Docker image #282

Closed kirmanak closed 3 years ago

kirmanak commented 3 years ago

Description

This pull request adds psycopg2 package to Docker image. The package is necessary to support PostgreSQL persistent storage. postgresql-dev package is added because it is a dependency of psycopg2.

Testing

To test this PR I recommend the following:

  1. Install PostgreSQL and create a db with user.
  2. Deploy the latest syncserver Docker image and configure it to use the PostgreSQL database.
  3. Check if "psycopg is required but not installed" error is present.
  4. Build a new Docker image with changes from this PR.
  5. Deploy it with the same configuration.
  6. Check if database scheme is created properly and the "psycopg2 isn't installed" error is gone.

Example docker-compose:

version: "3"
services:
  postgres:
    image: postgres:13
    restart: unless-stopped
    container_name: postgres
    volumes:
      - ./postgres:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: <password>

  syncserver:
    container_name: syncserver
    image: mozilla/syncserver:latest
    volumes:
       - ./syncserver:/data
    environment:
      SYNCSERVER_PUBLIC_URL: 'http://localhost:5000'
      SYNCSERVER_SECRET: '<secret>'
      SYNCSERVER_SQLURI: 'postgres://<user>:<pass>@postgres:5432/<dbname>'
      SYNCSERVER_BATCH_UPLOAD_ENABLED: 'true'
      SYNCSERVER_FORCE_WSGI_ENVIRON: 'false'
      PORT: '5000'
    restart: unless-stopped

Issue(s)

In issue it was recommended to install psycopg2 to support PostgreSQL. This recommendation can't be applied to Docker-based deployments. That's why I've decided to create the PR.

hanzoh commented 3 years ago

I have tested this PR and it works with postgres