-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.gitpod.Dockerfile
29 lines (24 loc) · 1.3 KB
/
.gitpod.Dockerfile
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
FROM gitpod/workspace-full:latest
# Dazzle does not rebuild a layer until one of its lines are changed. Increase this counter to rebuild this layer.
ENV TRIGGER_REBUILD=2
ENV PGWORKSPACE="/workspace/.pgsql"
ENV PGDATA="$PGWORKSPACE/data"
# Install PostgreSQL
RUN sudo install-packages postgresql-12 postgresql-contrib-12
# Setup PostgreSQL server for user gitpod
ENV PATH="/usr/lib/postgresql/12/bin:$PATH"
SHELL ["/usr/bin/bash", "-c"]
RUN PGDATA="${PGDATA//\/workspace/$HOME}" \
&& mkdir -p ~/.pg_ctl/bin ~/.pg_ctl/sockets $PGDATA \
&& initdb -D $PGDATA \
&& printf '#!/bin/bash\npg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" start\n' > ~/.pg_ctl/bin/pg_start \
&& printf '#!/bin/bash\npg_ctl -D $PGDATA -l ~/.pg_ctl/log -o "-k ~/.pg_ctl/sockets" stop\n' > ~/.pg_ctl/bin/pg_stop \
&& chmod +x ~/.pg_ctl/bin/* \
&& printf '%s\n' '# Auto-start PostgreSQL server' \
"test ! -e \$PGWORKSPACE && mkdir -p /workspace && test -e ${PGDATA%/data} && mv ${PGDATA%/data} /workspace" \
# Making the /workspace dir just to make sure it doesnt fail in docker env in case
'[[ $(pg_ctl status | grep PID) ]] || pg_start > /dev/null' > ~/.bashrc.d/200-postgresql-launch
ENV PATH="$HOME/.pg_ctl/bin:$PATH"
ENV PGHOSTADDR="127.0.0.1"
ENV PGDATABASE="postgres"
USER gitpod