5b840950c86c719f21049cf7e1456f0bad7b9e4f
TI1
The best thing to happen since yesterday at 2:56 pm
Usage
Start with getting Docker then do the following:
Create the setup files
Create a docker-compose.yml
services:
db:
image: postgres:17.2
container_name: postgres-db
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: RootPassword
POSTGRES_DB: ti1
ports:
- "5432:5432"
volumes:
- ./postgres_data:/var/lib/postgresql/data # Store data in the current directory
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
networks:
- app-network
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres", "-d", "ti1", "-h", "db"]
interval: 10s
retries: 5
restart: always # Ensure the container always restarts
valkey:
image: valkey/valkey:latest
container_name: valkey
environment:
VALKEY_PASSWORD: the_valkey_password
ports:
- "6379:6379"
volumes:
- ./valkey_data:/data
networks:
- app-network
restart: always # Ensure the container always restarts
ti1-container:
image: pigwin1/ti1:dev
container_name: ti1-container
environment:
DB_HOST: db
DB_PORT: 5432
DB_USER: ti1
DB_PASSWORD: ti1password
DB_NAME: ti1
DB_SSLMODE: disable
VALKEY_HOST: valkey
VALKEY_PORT: 6379
VALKEY_PASSWORD: the_valkey_password
depends_on:
db:
condition: service_healthy # Wait until the db service is healthy
valkey:
condition: service_started # Wait until the valkey service is started
networks:
- app-network
restart: always # Ensure the container always restarts
networks:
app-network:
driver: bridge
volumes:
postgres_data:
driver: local
valkey_data:
driver: local
Create init.sql
-- Check if 'post' user exists; create if not
DO $$
BEGIN
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'post') THEN
CREATE ROLE post WITH LOGIN PASSWORD 'postpassword';
GRANT ALL PRIVILEGES ON DATABASE ti1 TO post;
ALTER ROLE post WITH SUPERUSER;
END IF;
END
$$;
-- Check if 'ti1' user exists; create if not
DO $$
BEGIN
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'ti1') THEN
CREATE ROLE ti1 WITH LOGIN PASSWORD 'ti1password';
GRANT ALL PRIVILEGES ON DATABASE ti1 TO ti1;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO ti1;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO ti1;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public TO ti1;
-- Grant the ti1 user the necessary permissions on the public schema
GRANT USAGE, CREATE ON SCHEMA public TO ti1;
-- Grant all permissions (SELECT, INSERT, UPDATE, DELETE, etc.) on all existing tables in the public schema
GRANT ALL ON ALL TABLES IN SCHEMA public TO ti1;
-- Grant all permissions on all existing sequences in the public schema
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO ti1;
-- Grant all permissions on all functions in the public schema
GRANT ALL ON ALL FUNCTIONS IN SCHEMA public TO ti1;
-- Ensure that the ti1 user will have access to new tables, sequences, and functions created in the public schema
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO ti1;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO ti1;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON FUNCTIONS TO ti1;
-- Optionally, grant full permissions on the entire database to ti1 (if needed)
-- GRANT ALL PRIVILEGES ON DATABASE ti1 TO ti1;
END IF;
END
$$;
Remember to change the password values
Run the Docker Containers
docker compose up -d
edit the postgress config (optinal)
open the config file
nano postgres_data/postgresql.conf
Change the following values
listen_addresses = '*'
max_connections = 200
shared_buffers = 16GB
work_mem = 256MB
maintenance_work_mem = 2GB
dynamic_shared_memory_type = posix
max_wal_size = 1GB
min_wal_size = 80MB
set these to what makes most sense for you
These values should also be set bet not necessarily changed
log_timezone = 'Etc/UTC'
datestyle = 'iso, mdy'
timezone = 'Etc/UTC'
lc_messages = 'en_US.utf8'
lc_monetary = 'en_US.utf8'
lc_numeric = 'en_US.utf8'
lc_time = 'en_US.utf8'
default_text_search_config = 'pg_catalog.english'
Docker Hub Repository
You can find the Docker image on Docker Hub at the following link:
https://hub.docker.com/repository/docker/pigwin1/ti1/general
Description
Languages
Go
99.2%
Dockerfile
0.8%