forked from Appdynamics/jekyll-rtd-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.postgres
More file actions
41 lines (29 loc) · 1.22 KB
/
Dockerfile.postgres
File metadata and controls
41 lines (29 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
FROM postgres:latest
# Set environment variables for PostgreSQL configuration
ENV POSTGRES_USER=postgres \
POSTGRES_PASSWORD=slavepassword \
POSTGRES_DB=mydatabase
# Configure replication
RUN echo "host replication all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf && \
echo "primary_conninfo = 'host=master_ip port=5432 user=postgres password=masterpassword'" >> /var/lib/postgresql/data/postgresql.conf && \
echo "standby_mode = 'on'" > /var/lib/postgresql/data/recovery.conf
# Install Go (optional)
RUN apt-get update && apt-get install -y ca-certificates
RUN apt-get update && apt-get install -y golang && rm -rf /var/lib/apt/lists/*
# Copy application files
COPY ./app /app
# Set working directory for the Go application
WORKDIR /app
# Expose the PostgreSQL port and application port
EXPOSE 8081
# Ensure the data directory is empty
RUN rm -rf /var/lib/postgresql/data/*
# Copy initialization files
COPY ./init.sql /docker-entrypoint-initdb.d/init.sql
# Run PostgreSQL as the "postgres" user
# Copy the custom entrypoint script
COPY entrypoint.sh /entrypoint.sh
# Give it execute permissions
RUN chmod +x /entrypoint.sh
# Use custom entrypoint to start both PostgreSQL and the Go application
ENTRYPOINT ["/entrypoint.sh"]