fix: Added postgres-sql
This commit is contained in:
parent
05cb37730d
commit
16eced643c
2 changed files with 30 additions and 2 deletions
12
Dockerfile
12
Dockerfile
|
|
@ -18,9 +18,17 @@ RUN cargo build --release
|
||||||
|
|
||||||
# Stage 3: Final image
|
# Stage 3: Final image
|
||||||
FROM debian:bookworm-slim
|
FROM debian:bookworm-slim
|
||||||
RUN apt-get update && apt-get install -y ca-certificates libssl3 && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y ca-certificates libssl3 postgresql-16 && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV PATH="/usr/lib/postgresql/16/bin:$PATH"
|
||||||
|
ENV PGDATA=/var/lib/postgresql/data
|
||||||
|
ENV DATABASE_URL=postgres://mercury:mercury@127.0.0.1/mercury
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=api-builder /app/target/release/mercury .
|
COPY --from=api-builder /app/target/release/mercury .
|
||||||
COPY --from=ui-builder /ui/dist ./ui/dist
|
COPY --from=ui-builder /ui/dist ./ui/dist
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["./mercury"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|
|
||||||
20
entrypoint.sh
Normal file
20
entrypoint.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PGDATA="${PGDATA:-/var/lib/postgresql/data}"
|
||||||
|
PGLOG="/var/log/postgresql/postgresql.log"
|
||||||
|
|
||||||
|
mkdir -p "$PGDATA" /var/log/postgresql
|
||||||
|
chown postgres:postgres "$PGDATA" /var/log/postgresql
|
||||||
|
|
||||||
|
if [ ! -f "$PGDATA/PG_VERSION" ]; then
|
||||||
|
su -s /bin/sh postgres -c "initdb -D $PGDATA"
|
||||||
|
su -s /bin/sh postgres -c "pg_ctl start -D $PGDATA -w -l $PGLOG"
|
||||||
|
su -s /bin/sh postgres -c "psql postgres -c \"CREATE USER mercury WITH PASSWORD 'mercury';\""
|
||||||
|
su -s /bin/sh postgres -c "psql postgres -c \"CREATE DATABASE mercury OWNER mercury;\""
|
||||||
|
su -s /bin/sh postgres -c "pg_ctl stop -D $PGDATA -w"
|
||||||
|
fi
|
||||||
|
|
||||||
|
su -s /bin/sh postgres -c "pg_ctl start -D $PGDATA -w -l $PGLOG"
|
||||||
|
|
||||||
|
exec /app/mercury
|
||||||
Loading…
Reference in a new issue