@@ -13,10 +13,10 @@ COPY frontend/ ./
1313
1414# Copy .env file (with fallback to .env.production.example)
1515RUN if [ ! -f .env ]; then \
16- if [ -f .env.production.example ]; then \
17- cp .env.production.example .env; \
18- fi; \
19- fi
16+ if [ -f .env.production.example ]; then \
17+ cp .env.production.example .env; \
18+ fi; \
19+ fi
2020
2121RUN npm run build
2222
@@ -58,9 +58,9 @@ ARG TARGETOS
5858ARG TARGETARCH
5959ARG TARGETVARIANT
6060RUN CGO_ENABLED=0 \
61- GOOS=$TARGETOS \
62- GOARCH=$TARGETARCH \
63- go build -o /app/main ./cmd/main.go
61+ GOOS=$TARGETOS \
62+ GOARCH=$TARGETARCH \
63+ go build -o /app/main ./cmd/main.go
6464
6565
6666# ========= RUNTIME =========
@@ -71,22 +71,25 @@ ARG APP_VERSION=dev
7171LABEL org.opencontainers.image.version=$APP_VERSION
7272ENV APP_VERSION=$APP_VERSION
7373
74+ # Set production mode for Docker containers
75+ ENV ENV_MODE=production
76+
7477# Install PostgreSQL server and client tools (versions 13-17)
7578RUN apt-get update && apt-get install -y --no-install-recommends \
76- wget ca-certificates gnupg lsb-release sudo gosu && \
77- wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
78- echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
79- > /etc/apt/sources.list.d/pgdg.list && \
80- apt-get update && \
81- apt-get install -y --no-install-recommends \
82- postgresql-17 postgresql-client-13 postgresql-client-14 postgresql-client-15 \
83- postgresql-client-16 postgresql-client-17 && \
84- rm -rf /var/lib/apt/lists/*
79+ wget ca-certificates gnupg lsb-release sudo gosu && \
80+ wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
81+ echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
82+ > /etc/apt/sources.list.d/pgdg.list && \
83+ apt-get update && \
84+ apt-get install -y --no-install-recommends \
85+ postgresql-17 postgresql-client-13 postgresql-client-14 postgresql-client-15 \
86+ postgresql-client-16 postgresql-client-17 && \
87+ rm -rf /var/lib/apt/lists/*
8588
8689# Create postgres user and set up directories
8790RUN useradd -m -s /bin/bash postgres || true && \
88- mkdir -p /postgresus-data/pgdata && \
89- chown -R postgres:postgres /postgresus-data/pgdata
91+ mkdir -p /postgresus-data/pgdata && \
92+ chown -R postgres:postgres /postgresus-data/pgdata
9093
9194WORKDIR /app
9295
@@ -105,10 +108,10 @@ COPY --from=backend-build /app/ui/build ./ui/build
105108# Copy .env file (with fallback to .env.production.example)
106109COPY backend/.env* /app/
107110RUN if [ ! -f /app/.env ]; then \
108- if [ -f /app/.env.production.example ]; then \
109- cp /app/.env.production.example /app/.env; \
110- fi; \
111- fi
111+ if [ -f /app/.env.production.example ]; then \
112+ cp /app/.env.production.example /app/.env; \
113+ fi; \
114+ fi
112115
113116# Create startup script
114117COPY <<EOF /app/start.sh
160163echo "Setting up database and user..."
161164gosu postgres \$ PG_BIN/psql -p 5437 -h localhost -d postgres << 'SQL'
162165ALTER USER postgres WITH PASSWORD 'Q1234567' ;
163- CREATE DATABASE "postgresus" OWNER postgres;
166+ SELECT 'CREATE DATABASE postgresus OWNER postgres'
167+ WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'postgresus' )\g exec
164168\q
165169SQL
166170
0 commit comments