R
RailwayFaruq Alli-Balogun

How do I create a template from the following Docker files?

Dockerfile
FROM postgres:16-alpine3.19

RUN apk -U add --no-cache \
alpine-sdk \
curl-dev \
clang15 \
llvm15 \
perl

RUN git clone https://github.com/supabase/pg_net.git

RUN cd pg_net && \
make && make install

RUN cd / && \
rm -rf pg_net && \
apk cache clean

RUN echo '#!/bin/bash' > /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'set -e' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'CREATE USER postgres;' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'ALTER ROLE postgres SUPERUSER;' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'CREATE EXTENSION IF NOT EXISTS pg_net;' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'EOSQL' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
chmod +x /docker-entrypoint-initdb.d/00-pg-net.sh
FROM postgres:16-alpine3.19

RUN apk -U add --no-cache \
alpine-sdk \
curl-dev \
clang15 \
llvm15 \
perl

RUN git clone https://github.com/supabase/pg_net.git

RUN cd pg_net && \
make && make install

RUN cd / && \
rm -rf pg_net && \
apk cache clean

RUN echo '#!/bin/bash' > /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'set -e' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'CREATE USER postgres;' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'ALTER ROLE postgres SUPERUSER;' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'CREATE EXTENSION IF NOT EXISTS pg_net;' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
echo 'EOSQL' >> /docker-entrypoint-initdb.d/00-pg-net.sh && \
chmod +x /docker-entrypoint-initdb.d/00-pg-net.sh
docker-compose.yml
version: '3.7'

services:
postgres:
build:
context: .
image: postgresql:16-alpine3.19-pg_net
ports:
- '5432:5432'
command: postgres -c shared_preload_libraries=pg_net -c pg_net.database_name=${POSTGRES_DB} -c max_connections=200
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped

volumes:
postgres_data:
version: '3.7'

services:
postgres:
build:
context: .
image: postgresql:16-alpine3.19-pg_net
ports:
- '5432:5432'
command: postgres -c shared_preload_libraries=pg_net -c pg_net.database_name=${POSTGRES_DB} -c max_connections=200
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped

volumes:
postgres_data:
B
Brody18d ago
can you help me to understand this? the dockerfile is for postgres and the docker compose file also deploys postgres?
FA
Faruq Alli-Balogun16d ago
I'm installing a supbase postgres extension called pg_net There are some steps required to get installed, which is installing packages, cloning the git repo and actually installing it Then we have to set these values shared_preload_libraries = pg_net pg_net.database_name = ${POSTGRES_DB} Then we run this command CREATE EXTENSION IF NOT EXISTS pg_net; And that's all
B
Brody16d ago
in the docker compose file it looks like a pre-built image for that already exists, why not just deploy the standard postgres database on railway and then swap it's source image for your desired image?
FA
Faruq Alli-Balogun13d ago
Basically beecause I have the run this compose postgres -c shared_preload_libraries=pg_net -c pg_net.database_name=${POSTGRES_DB} -c max_connections=200 Which I'm currently running in my docker compose
B
Brody13d ago
what's stopping you from put that as the start command?
/bin/sh -c "exec postgres -c shared_preload_libraries=pg_net -c pg_net.database_name=${POSTGRES_DB} -c max_connections=200"
/bin/sh -c "exec postgres -c shared_preload_libraries=pg_net -c pg_net.database_name=${POSTGRES_DB} -c max_connections=200"
FA
Faruq Alli-Balogun10d ago
Hi so I did this and app has been deploying for 5 minutes Logs are empty Here's a link to the image https://hub.docker.com/r/babkum/postgres-essentials
FA
Faruq Alli-Balogun10d ago
And a link to the Github repository https://github.com/babkum/postgres-essentials
GitHub
GitHub - Babkum/postgres-essentials: A postgres image with some ext...
A postgres image with some extensions built-in. Contribute to Babkum/postgres-essentials development by creating an account on GitHub.
B
Brody10d ago
show me what you changed after deploying the standard postgres database
FA
Faruq Alli-Balogun10d ago
Ok I took a different approach now, you can check the same repo Application is deploying and starting fine now but can't connect I'm not sure but I think it's a common issue
FA
Faruq Alli-Balogun10d ago
No description
FA
Faruq Alli-Balogun10d ago
How can I fix it?
B
Brody10d ago
the tcp proxy most certainly isn't using port 5432
FA
Faruq Alli-Balogun10d ago
Ok I tried the other port and didn't work The other port being the one in the env
FA
Faruq Alli-Balogun10d ago
No description
FA
Faruq Alli-Balogun10d ago
No description
B
Brody10d ago
this screenshot is cut off did you really open 7 duplicate threads?
FA
Faruq Alli-Balogun9d ago
Oh no I think it’s a bug. I clicked on Submit, I didn’t get any feedback and the pop up was still open So I thought I had network issues That’s where the error is
B
Brody9d ago
interesting, alright fair enough I can't blame you for that then haha
Want results from more Discord servers?
Add your server
More Posts
Is it possible to use Redis?After all that has happened to Redis, is it still possible to create a Docker image and update it toIs it possible to use Redis?After all that has happened to Redis, is it still possible to create a Docker image and receive updaWatch paths to ignore on PR deployment (preview)I have watch paths set on the `preview` environment, but am still seeing instances spin up for new PPayment fails on portal but is success on Visa appWhen I try to subscribe to hobby plan, my payment fails on the railway site with "card declined" wheCannot change nixpkgsArchive hash from railway.tomlHello, seems like I can't change the nixpkgs archive version from railway.toml ``` [build] builder =can i use railway postgres db with @vercel/postgres ?I am try trying to use railway postgress db with @vercel/postgres. Is it compatible? How do I map raIssue Deploying Django App with Gunicorn on RailwayIt's been a few days of trying to get this up for some production tests but I'm having issues gettinPrisma Nickpacks with Bun errorWhen trying to build nixpacks with bun and prisma using this config: ```toml # nixpacks.toml [phasesHow to retrieve env vars from railway?I need to use them in github action and I don't want to have them as a secret in github as well as iDjango app, slow server responseI am having django app, regular django templates. Database is on google cloud. This is railway reMongoDB prismaWhen ever i try to connect my mongodb with prisma i does not work :( when i genarate the schema it gAccessing an image within a railway. app PGS databaseHi all, Absolutely love Railway.app but just wondering if anyone can assist with accessing an imagincorrect cron time trigger@Brody I'm using your template (https://railway.app/template/fwH-l3) and it seems to trigger at incoHow do I connect Webste <-> Server <-> Database❓Github code for Main website in public and server.js https://github.com/Lanonymus/todowebsite/tree/mDevika DeployProject ID: ec66fb06-96a7-4f3e-8481-72f97991dc35 Hello, I am trying to deploy Github project DevikaLaravel Image upload returns 413 (file too large)Hi, I have endpoint in my laravel app that uploads images but it returns with the status code of 413RAILWAY_TCP_PROXY_DOMAIN and RAILWAY_TCP_PROXY_PORT are emptyI noticed this morning, in my Postgres database PGPORT is set ${{RAILWAY_TCP_PROXY_PORT}} but it's eInvalid Cache MountsRunning into a wall with trying to run a fairly straightforward Go HTTP server. Using the newer featDownload built image from railway or ssh access to service.Hey folks. I'm debugging an issue with my deployment and it would really help if there was a way to Services is not showing up?So my services in my projects is not showing up for some reason?