Skip to content

Instantly share code, notes, and snippets.

@carmenlau
Last active January 22, 2019 07:20
Show Gist options
  • Save carmenlau/6bc18711f0b672b4402c5fc4d2f3c6d4 to your computer and use it in GitHub Desktop.
Save carmenlau/6bc18711f0b672b4402c5fc4d2f3c6d4 to your computer and use it in GitHub Desktop.
Skygear next docker setup
  1. Create schema in db

    CREATE SCHEMA app_config;
    CREATE SCHEMA app_next;
    
  2. Run migration

    # Build the docker image
    docker build -f ./cmd/migrate/Dockerfile -t skygear-migrate .
    
    # Run migration
    docker run --rm --network=host skygear-migrate -module=gateway up
    docker run --rm --network=host skygear-migrate -module=core -schema=app_next up
    docker run --rm --network=host skygear-migrate -module=auth -schema=app_next up
    
  3. Run init sql in gateway db, check gateway-init-data.sql

  4. Access api through

    Endpoint: http://127.0.0.1:3001
    API key: api_key
    Master key: master_key
    
  5. (Optional) If you want to change the app config, update config field of config table in gateway db.

version: '2.3'
services:
db:
image: mdillon/postgis:9.5
volumes:
- next_db_data:/var/lib/postgresql/data
ports:
- "5432:5432"
gateway:
build:
context: .
dockerfile: ./cmd/gateway/Dockerfile
ports:
- "3001:3000"
environment:
HOST: 0.0.0.0:3000
DATABASE_URL: postgresql://postgres:@db/postgres?sslmode=disable
AUTH_LIVE_URL: http://auth:3000
AUTH_PREVIOUS_URL: http://auth:3000
AUTH_NIGHTLY_URL: http://auth:3000
auth:
build:
context: .
dockerfile: ./cmd/auth/Dockerfile
environment:
HOST: 0.0.0.0:3000
DEV_MODE: 'false'
volumes:
next_db_data:
driver: local
BEGIN;
SET search_path TO app_config;
INSERT INTO "plan" ("id","created_at","updated_at","name","auth_enabled","record_enabled")
VALUES
(E'f741807e-062a-4069-a193-1097c3b407b7',E'2018-09-06 00:00:00',E'2018-09-06 00:00:00',E'free',TRUE,FALSE);
INSERT INTO "config" ("id", "created_at", "updated_at", "config", "app_id")
VALUES
('014fa58c-ebc1-427c-b39c-ad110273fd17', '2018-09-06 00:00:00', '2018-09-06 00:00:00', '{"API_KEY": "api_key", "APP_NAME": "next", "MASTER_KEY": "master_key", "TOKEN_STORE": {"EXPIRY": 0, "SECRET": "secret"}, "DATABASE_URL": "postgresql://postgres:@db/postgres?sslmode=disable"}', 'dc6e9a6c-ce1c-4fed-9a8c-5a859a8f63eb');
INSERT INTO "app" ("id","created_at","updated_at","name","plan_id","config_id","auth_version","record_version")
VALUES
(E'dc6e9a6c-ce1c-4fed-9a8c-5a859a8f63eb',E'2018-09-06 00:00:00',E'2018-09-06 00:00:00',E'next',E'f741807e-062a-4069-a193-1097c3b407b7',E'014fa58c-ebc1-427c-b39c-ad110273fd17',E'live',E'live');
INSERT INTO "domain" ("id","created_at","updated_at","domain","app_id")
VALUES
(E'd23a3381-dfe6-465f-95e6-1870f47787df',E'2018-09-06 00:00:00',E'2018-09-06 00:00:00',E'127.0.0.1:3001',E'dc6e9a6c-ce1c-4fed-9a8c-5a859a8f63eb');
SET search_path TO DEFAULT;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment