DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

Where can I host PostgreSQL with custom extensions for cheap (or free)?

Of course, I can easily host on DigitalOcean, but there will be price per month; and at least half a hundred USD per year.

I can host on Heroku, but not only that there are limited 10k rows, but also no custom extensions.

I open-sourced the repo, anyway; and one can use it to make Anki. But I want to service further, and get more audience. (But I won't want to cost my wallet too much.)

GitHub logo patarapolw / cjclub

Chinese-Japanese Character and Vocabulary club

What extensions? You can see my Dockerfile.

# Based on debian-slim
FROM postgres:12

RUN mkdir -p /app
RUN apt-get update

# pgroonga extension
# Does not officially support alpine
RUN apt-get install -y wget
RUN wget https://packages.groonga.org/debian/groonga-apt-source-latest-buster.deb
RUN apt install -y -V ./groonga-apt-source-latest-buster.deb
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get update
RUN apt-get install -y -V postgresql-12-pgdg-pgroonga
RUN apt-get install -y -V groonga-tokenizer-mecab
RUN apt-get install -y -V groonga-token-filter-stem

RUN apt-get install -y git make

# postgres-json-schema extension
WORKDIR /app
RUN git clone --depth 1 https://github.com/gavinwahl/postgres-json-schema.git
RUN cd postgres-json-schema && make install

# groonga-tokenizer-friso extension
# WORKDIR /app
# RUN apt-get install -y build-essential automake libtool libgroonga-dev
# RUN git clone --depth 1 https://github.com/kenhys/groonga-tokenizer-friso.git
# RUN wget -c https://github.com/lionsoul2014/friso/archive/v1.6.4-release.tar.gz -O - | tar -xz
# RUN cd friso-1.6.4-release/src && make && make install
# RUN cd groonga-tokenizer-friso && ./autogen.sh && ./configure --with-friso=/usr --with-friso-ini=../friso-1.6.4-release/friso.ini && make && make install

# pg_jieba extension
WORKDIR /app
RUN apt-get install -y cmake build-essential postgresql-server-dev-12
RUN git clone --depth 1 https://github.com/jaiminpan/pg_jieba.git
WORKDIR /app/pg_jieba
RUN git submodule update --init --recursive
RUN mkdir build && cd build && cmake -DPostgreSQL_TYPE_INCLUDE_DIR=/usr/include/postgresql/12/server .. && make && make install
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
scalegridio profile image
ScaleGrid

You can check out ScaleGrid's PostgreSQL hosting - it supports all PostgreSQL extensions and is available on DigitalOcean, Linode, AWS, Azure, GCP and OCI. scalegrid.io/postgresql.html