Skip to content

Commit

Permalink
Merge pull request #3 from cscenter/master
Browse files Browse the repository at this point in the history
postgresql docker image
  • Loading branch information
Pavel Sviderski committed Oct 21, 2015
2 parents 8521d57 + ffd2035 commit 29a2490
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
28 changes: 28 additions & 0 deletions challenge-dbms/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ubuntu:14.04
MAINTAINER Pavel Sviderski <[email protected]>

RUN apt-get update && apt-get --no-install-recommends -y install \
man openssh-server wget python-pip \
vim nano screen tmux \
binutils build-essential gdb ltrace strace \
sqlite sqlite3 \
postgresql postgresql-client \
&& apt-get clean \
&& useradd -m box

RUN sed -i 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config \
&& sed -i 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config \
&& echo "box ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/box

COPY common/ssh /root/.ssh
COPY common/bashrc /root/.bashrc

COPY challenge-dbms/start.sh /.box/start.sh
COPY challenge-dbms/init-postgresql.sh /.box/init-postgresql.sh
COPY challenge-dbms/bashrc /home/box/.bashrc

COPY common/greeting /.box/greeting

EXPOSE 22

CMD /.box/start.sh
6 changes: 6 additions & 0 deletions challenge-dbms/bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PS1='\[\033[01;32m\]\u\[\033[01;33m\]@\[\033[01;32m\]\h: \[\033[01;33m\]\w \[\033[01;35m\]\$ \[\033[00m\]'
alias ls="ls --color=auto"
export PGPASSWORD="box"
alias psql="psql -h localhost"

cd ~/
10 changes: 10 additions & 0 deletions challenge-dbms/init-postgresql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# This script was copied from PostgreSQL Docker image.
# Original sources: https://github.com/docker-library/postgres/blob/ed23320582f4ec5b0e5e35c99d98966dacbc6ed8/9.4/docker-entrypoint.sh
sudo service postgresql start
export POSTGRES_PASSWORD="box"
export POSTGRES_USER="box"

sudo -u postgres psql -c "CREATE USER ${POSTGRES_USER} WITH PASSWORD '${POSTGRES_PASSWORD}' SUPERUSER;"
export PGPASSWORD="${POSTGRES_PASSWORD}"
createdb -h localhost -U $POSTGRES_USER $POSTGRES_USER
16 changes: 16 additions & 0 deletions challenge-dbms/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

/sbin/my_init --skip-startup-files &>/dev/null &
echo "Initializing PostgreSQL..."
/.box/init-postgresql.sh
echo "...done. Type psql to start the PostgreSQL shell"

echo "Press ENTER to start hacking..."
trap '' 2 # mock SIGINT on CTRL+C
read
trap 2 # enable SIGINT

cat /.box/greeting
while true; do
su box
done

0 comments on commit 29a2490

Please sign in to comment.