supabase-dev attempt 1: we have the docker container extending our realtime server, but we need to get all commands working together. At the moment only one is running at a time

This commit is contained in:
Paul Copplestone committed 2020-01-13 09:44:05 +08:00
1 parent 1838c352e1
commit f1ca81f18c
19 files changed
+176 -146

No files matched your search

View File
File renamed without changes.
File renamed without changes.
+70
View File
@@ -0,0 +1,70 @@
FROM supabase/realtime:latest
ARG POSTGREST_VERSION="v6.0.2"
ENV DB_HOST=localhost \
DB_NAME=postgres \
DB_USER=postgres \
DB_PASSWORD=postgres \
DB_PORT=5432 \
PGRST_DB_URI= \
PGRST_DB_SCHEMA=public \
PGRST_DB_ANON_ROLE= \
PGRST_DB_POOL=100 \
PGRST_DB_EXTRA_SEARCH_PATH=public \
PGRST_SERVER_HOST=*4 \
PGRST_SERVER_PORT=3000 \
PGRST_SERVER_PROXY_URI= \
PGRST_JWT_SECRET= \
PGRST_SECRET_IS_BASE64=false \
PGRST_JWT_AUD= \
PGRST_MAX_ROWS= \
PGRST_PRE_REQUEST= \
PGRST_ROLE_CLAIM_KEY=".role" \
PGRST_ROOT_SPEC= \
PGRST_RAW_MEDIA_TYPES=
RUN apt-get update
# Install libpq5
RUN apt-get -qq install -y --no-install-recommends libpq5 && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install postgrest
RUN BUILD_DEPS="curl ca-certificates xz-utils" && \
apt-get -qq update && \
apt-get -qq install -y --no-install-recommends $BUILD_DEPS && \
cd /tmp && \
curl -SLO https://github.com/PostgREST/postgrest/releases/download/${POSTGREST_VERSION}/postgrest-${POSTGREST_VERSION}-ubuntu.tar.xz && \
tar -xJvf postgrest-${POSTGREST_VERSION}-ubuntu.tar.xz && \
mv postgrest /usr/local/bin/postgrest && \
cd / && \
apt-get -qq purge --auto-remove -y $BUILD_DEPS && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY postgrest.conf /etc/postgrest.conf
RUN groupadd -g 1000 postgrest && \
useradd -r -u 1000 -g postgrest postgrest && \
chown postgrest:postgrest /etc/postgrest.conf
# Add user to Realtime
RUN chown -R postgrest:postgrest /prod/rel/realtime/
ADD start.sh /
RUN chmod +x /start.sh
USER 1000
EXPOSE 3000
EXPOSE 4000
CMD ["/start.sh"]
# PostgREST reads /etc/postgrest.conf so map the configuration
# file in when you run this container
# CMD exec postgrest /etc/postgrest.conf
# CMD ["sh", "-c", "/prod/rel/realtime/bin/realtime start ; exec postgrest /etc/postgrest.conf"]
# docker build . -t supabase --pull --no-cache
+19
View File
@@ -0,0 +1,19 @@
db-uri = "$(PGRST_DB_URI)"
db-schema = "$(PGRST_DB_SCHEMA)"
db-anon-role = "$(PGRST_DB_ANON_ROLE)"
db-pool = "$(PGRST_DB_POOL)"
db-extra-search-path = "$(PGRST_DB_EXTRA_SEARCH_PATH)"
server-host = "$(PGRST_SERVER_HOST)"
server-port = "$(PGRST_SERVER_PORT)"
server-proxy-uri = "$(PGRST_SERVER_PROXY_URI)"
jwt-secret = "$(PGRST_JWT_SECRET)"
secret-is-base64 = "$(PGRST_SECRET_IS_BASE64)"
jwt-aud = "$(PGRST_JWT_AUD)"
role-claim-key = "$(PGRST_ROLE_CLAIM_KEY)"
max-rows = "$(PGRST_MAX_ROWS)"
pre-request = "$(PGRST_PRE_REQUEST)"
root-spec = "$(PGRST_ROOT_SPEC)"
raw-media-types = "$(PGRST_RAW_MEDIA_TYPES)"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
exec postgrest /etc/postgrest.conf &
/prod/rel/realtime/bin/realtime start &
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+53
View File
@@ -0,0 +1,53 @@
--
-- Name: cities; Type: TABLE; Schema: public; Owner: supabase
--
CREATE TABLE public.cities (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name character varying(255) NOT NULL,
country_id integer NOT NULL
);
--
-- Name: countries; Type: TABLE; Schema: public; Owner: supabase
--
CREATE TABLE public.countries (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name character varying(255) NOT NULL,
iso2 character varying(5) NOT NULL,
continent character varying(255) NOT NULL
);
--
-- Data for Name: cities; Type: TABLE DATA; Schema: public; Owner: supabase
--
COPY public.cities (id, name, country_id) FROM stdin;
1 Rio de Janeiro 1
2 Beijing 2
3 Paris 3
4 Auckland 4
5 Lagos 5
6 San Francisco 6
\.
--
-- Data for Name: countries; Type: TABLE DATA; Schema: public; Owner: supabase
--
COPY public.countries (id, name, iso2, continent) FROM stdin;
1 Brazil BR South America
2 China CN Asia
3 France FR Europe
4 New Zealand NZ Oceania
5 Nigeria NG Africa
6 United States US North America
\.
+30
View File
@@ -0,0 +1,30 @@
version: '3'
services:
supabase:
build: ./dev/docker
ports:
- "4000:4000"
- "3000:3000"
environment:
DB_HOST: db
DB_NAME: postgres
DB_USER: postgres
DB_PASSWORD: postgres
DB_PORT: 5432
APP_PORT: 4000
APP_HOSTNAME: localhost
SECRET_KEY_BASE: SOMETHING_SUPER_SECRET
PGRST_DB_URI: postgres://postgres:postgres@db:5432/postgres
PGRST_DB_SCHEMA: public
PGRST_DB_ANON_ROLE: postgres
depends_on:
- db
# command: ["sh", "-c", "/prod/rel/realtime/bin/realtime start ; exec postgrest /etc/postgrest.conf"]
command: ["/start.sh"]
db:
build: ./dev/postgres
ports:
- "5432:5432"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-146
View File
@@ -1,146 +0,0 @@
--
-- PostgreSQL database dump
--
-- Dumped from database version 11.2
-- Dumped by pg_dump version 11.2
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: cities; Type: TABLE; Schema: public; Owner: supabase
--
CREATE TABLE public.cities (
id bigint NOT NULL,
name character varying(255) NOT NULL,
country_id integer NOT NULL
);
ALTER TABLE public.cities OWNER TO supabase;
--
-- Name: cities_id_seq; Type: SEQUENCE; Schema: public; Owner: supabase
--
ALTER TABLE public.cities ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.cities_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Name: countries; Type: TABLE; Schema: public; Owner: supabase
--
CREATE TABLE public.countries (
id bigint NOT NULL,
name character varying(255) NOT NULL,
iso2 character varying(5) NOT NULL,
continent character varying(255) NOT NULL
);
ALTER TABLE public.countries OWNER TO supabase;
--
-- Name: countries_id_seq; Type: SEQUENCE; Schema: public; Owner: supabase
--
ALTER TABLE public.countries ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public.countries_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);
--
-- Data for Name: cities; Type: TABLE DATA; Schema: public; Owner: supabase
--
COPY public.cities (id, name, country_id) FROM stdin;
1 Rio de Janeiro 1
2 Beijing 2
3 Paris 3
4 Auckland 4
5 Lagos 5
6 San Francisco 6
\.
--
-- Data for Name: countries; Type: TABLE DATA; Schema: public; Owner: supabase
--
COPY public.countries (id, name, iso2, continent) FROM stdin;
1 Brazil BR South America
2 China CN Asia
3 France FR Europe
4 New Zealand NZ Oceania
5 Nigeria NG Africa
6 United States US North America
\.
--
-- Name: cities_id_seq; Type: SEQUENCE SET; Schema: public; Owner: supabase
--
SELECT pg_catalog.setval('public.cities_id_seq', 6, true);
--
-- Name: countries_id_seq; Type: SEQUENCE SET; Schema: public; Owner: supabase
--
SELECT pg_catalog.setval('public.countries_id_seq', 6, true);
--
-- Name: cities cities_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase
--
ALTER TABLE ONLY public.cities
ADD CONSTRAINT cities_pkey PRIMARY KEY (id);
--
-- Name: countries countries_pkey; Type: CONSTRAINT; Schema: public; Owner: supabase
--
ALTER TABLE ONLY public.countries
ADD CONSTRAINT countries_pkey PRIMARY KEY (id);
--
-- Name: cities cities_countries_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: supabase
--
ALTER TABLE ONLY public.cities
ADD CONSTRAINT cities_countries_id_fkey FOREIGN KEY (country_id) REFERENCES public.countries(id) ON DELETE CASCADE;
--
-- PostgreSQL database dump complete
--