File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -18,15 +18,11 @@ RUN PGDATA="${PGDATA//\/workspace/$HOME}" \
18
18
&& initdb -D $PGDATA \
19
19
&& printf '#!/bin/bash\n pg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" start\n ' > ~/.pg_ctl/bin/pg_start \
20
20
&& printf '#!/bin/bash\n pg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" stop\n ' > ~/.pg_ctl/bin/pg_stop \
21
- && chmod +x ~/.pg_ctl/bin/* \
22
- && printf '%s\n ' '# Auto-start PostgreSQL server' \
23
- '(' \
24
- "mkdir \$ PGWORKSPACE 2>/dev/null || exit 0; test -e ${PGDATA%/data} && mv ${PGDATA%/data} /workspace" \
25
- '[[ $(pg_ctl status | grep PID) ]] || pg_start > /dev/null' \
26
- ') & disown' > ~/.bashrc.d/200-postgresql-launch
21
+ && chmod +x ~/.pg_ctl/bin/*
27
22
ENV PATH="$HOME/.pg_ctl/bin:$PATH"
28
23
ENV DATABASE_URL="postgresql://gitpod@localhost"
29
24
ENV PGHOSTADDR="127.0.0.1"
30
25
ENV PGDATABASE="postgres"
26
+ COPY --chown=gitpod:gitpod postgresql-hook.bash $HOME/.bashrc.d/200-postgresql-launch
31
27
32
28
USER gitpod
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # Auto-start PostgreSQL server
3
+ (
4
+ if mkdir /tmp/.pgsql_lock 2> /dev/null; then {
5
+ target=" ${PGWORKSPACE} "
6
+ source=" ${target// \/ workspace/ $HOME } "
7
+
8
+ if test -e " $source " ; then {
9
+
10
+ if test ! -e " $target " ; then {
11
+ mv " $source " " $target "
12
+ }; fi
13
+
14
+ if ! [[ " $( pg_ctl status) " =~ PID ]]; then {
15
+ pg_start > /dev/null
16
+ trap " pg_stop" TERM EXIT
17
+ exec {sfd}<> <( :)
18
+ until read -r -t 3600 -u $sfd ; do continue ; done
19
+ }; fi
20
+
21
+ }; fi
22
+ }; fi
23
+ ) &
24
+ disown
You can’t perform that action at this time.
0 commit comments