Skip to content

Commit

Permalink
Configure postgres with pg_profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Romanow committed Oct 15, 2024
1 parent 748458c commit 66a6cec
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
* [Logging](logging/README.md)
* [Tracing](tracing/README.md)
* [Elastic](elastic/README.md)
* [Minio](minio/README.md)
* [Frontend](frontend/README.md)
* [Java](java/README.md)
8 changes: 8 additions & 0 deletions minio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Minio

```shell
$ mc alias set local http://localhost:9000 program qwerty123
$ mc mb local/my-bucket
$ mc mv data.txt local/my-bucket/

```
53 changes: 53 additions & 0 deletions minio/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: "3.9"

x-minio-common: &minio-common
image:
minio/minio:latest
command: server --console-address ":9001" http://minio-{1...2}/data
expose:
- "9000"
- "9001"
environment:
MINIO_ROOT_USER: program
MINIO_ROOT_PASSWORD: qwerty123
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:9000/minio/health/live" ]
interval: 30s
timeout: 20s
retries: 3

services:
minio-1:
<<: *minio-common
hostname: minio-1
volumes:
- data1:/data

minio-2:
<<: *minio-common
hostname: minio-2
volumes:
- data2:/data

nginx:
image: nginx:1.25-alpine
hostname: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "9000:9000"
- "9001:9001"
healthcheck:
test: "curl --fail http://localhost:9001 || exit 1"
interval: 10s
timeout: 5s
retries: 5
depends_on:
minio-1:
condition: service_healthy
minio-2:
condition: service_healthy

volumes:
data1:
data2:
87 changes: 87 additions & 0 deletions minio/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 4096;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;

upstream minio {
server minio-1:9000;
server minio-2:9000;
}

upstream console {
ip_hash;
server minio-1:9001;
server minio-2:9001;
}

server {
listen 9000;
server_name localhost;

ignore_invalid_headers off;
client_max_body_size 0;
proxy_buffering off;
proxy_request_buffering off;

location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_connect_timeout 300;
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;

proxy_pass http://minio;
}
}

server {
listen 9001;
server_name localhost;

ignore_invalid_headers off;
client_max_body_size 0;
proxy_buffering off;
proxy_request_buffering off;

location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-NginX-Proxy true;

real_ip_header X-Real-IP;

proxy_connect_timeout 300;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

chunked_transfer_encoding off;

proxy_pass http://console;
}
}
}
2 changes: 1 addition & 1 deletion postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM postgres:15
RUN apt-get update && \
apt-get install curl -y && \
curl -L -o /tmp/pg_profile.tar.gz https://github.com/zubkov-andrei/pg_profile/releases/download/4.7/pg_profile--4.7.tar.gz && \
tar -xf /tmp/pg_profile.tar.gz -C $(pg_config --sharedir)/extension \
tar -xf /tmp/pg_profile.tar.gz -C $(pg_config --sharedir)/extension

0 comments on commit 66a6cec

Please sign in to comment.