-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# FROM ubuntu:xenial | ||
FROM openjdk:8-jdk | ||
LABEL maintainer="Andrey Antukh <[email protected]>" | ||
|
||
ARG EXTERNAL_UID=1000 | ||
|
||
ENV CLOJURE_VERSION=1.10.0.442 \ | ||
LANG=en_US.UTF-8 \ | ||
LC_ALL=C.UTF-8 | ||
|
||
RUN set -ex; \ | ||
apt-get update && \ | ||
apt-get install -yq \ | ||
locales \ | ||
ca-certificates \ | ||
wget \ | ||
sudo \ | ||
curl \ | ||
bash \ | ||
zsh \ | ||
git \ | ||
rlwrap \ | ||
; \ | ||
rm -rf /var/lib/apt/lists/*; | ||
|
||
RUN set -ex; \ | ||
echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" >> /etc/apt/sources.list; \ | ||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -; \ | ||
apt-get update -yq && \ | ||
apt-get install -yq \ | ||
postgresql-9.6 \ | ||
postgresql-contrib-9.6 \ | ||
;\ | ||
rm -rf /var/lib/apt/lists/*; | ||
|
||
COPY pg_hba.conf /etc/postgresql/9.6/main/pg_hba.conf | ||
|
||
# Copy user config files | ||
COPY bashrc /root/.bashrc | ||
COPY zshrc /root/.zshrc | ||
COPY vimrc /root/.vimrc | ||
COPY entrypoint.sh /entrypoint.sh | ||
COPY tmux.conf /root/.tmux.conf | ||
|
||
RUN set -ex; \ | ||
/etc/init.d/postgresql start \ | ||
&& createuser -U postgres -sl devuser \ | ||
&& createdb -U devuser test \ | ||
&& /etc/init.d/postgresql stop | ||
|
||
RUN set -ex; \ | ||
wget "https://download.clojure.org/install/linux-install-$CLOJURE_VERSION.sh"; \ | ||
chmod +x "linux-install-$CLOJURE_VERSION.sh"; \ | ||
"./linux-install-$CLOJURE_VERSION.sh"; \ | ||
rm -rf "linux-install-$CLOJURE_VERSION.sh" | ||
|
||
RUN set -ex; \ | ||
useradd -m -g users -s /bin/zsh -u $EXTERNAL_UID devuser; \ | ||
passwd devuser -d; \ | ||
echo "devuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
||
USER devuser | ||
WORKDIR /home/devuser | ||
|
||
# Copy user config files | ||
COPY bashrc /home/devuser/.bashrc | ||
COPY zshrc /home/devuser/.zshrc | ||
COPY vimrc /home/devuser/.vimrc | ||
COPY tmux.conf /home/devuser/.tmux.conf | ||
|
||
ENTRYPOINT ["zsh", "/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export PATH=$HOME/.local/bin:$PATH | ||
|
||
alias l='ls --color -GFlh' | ||
alias rm='rm -r' | ||
alias ls='ls --color -F' | ||
alias lsd='ls -d *(/)' | ||
alias lsf='ls -h *(.)' | ||
|
||
export LEIN_FAST_TRAMPOLINE=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env zsh | ||
set -ex | ||
sudo pg_ctlcluster 9.6 main start | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Database administrative login by Unix domain socket | ||
local all postgres trust | ||
|
||
# TYPE DATABASE USER ADDRESS METHOD | ||
|
||
# "local" is for Unix domain socket connections only | ||
local all all trust | ||
# IPv4 local connections: | ||
host all all 127.0.0.1/32 trust | ||
# IPv6 local connections: | ||
host all all ::1/128 trust |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set -g mouse off | ||
set -g history-limit 50000 | ||
setw -g mode-keys emacs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
set nocompatible | ||
|
||
set bs=2 | ||
set ts=4 | ||
set tw=1000000000 | ||
|
||
set expandtab | ||
set tabstop=8 | ||
set softtabstop=4 | ||
set shiftwidth=4 | ||
filetype indent off | ||
filetype plugin on | ||
|
||
syntax on | ||
|
||
set autoindent | ||
set showmatch | ||
set showmode | ||
set mousehide | ||
|
||
set nowrapscan | ||
set hlsearch | ||
set incsearch | ||
|
||
set fileencoding=utf8 | ||
set encoding=utf8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env zsh | ||
|
||
export EDITOR=vim | ||
|
||
bindkey "^[[3~" delete-char | ||
bindkey "^[3;5~" delete-char | ||
bindkey '^R' history-incremental-search-backward | ||
|
||
bindkey -e | ||
|
||
autoload -U promptinit | ||
promptinit | ||
prompt off | ||
|
||
#------------------------------ | ||
## Comp stuff | ||
##------------------------------ | ||
zmodload zsh/complist | ||
autoload -Uz compinit | ||
compinit | ||
|
||
#------------------------------ | ||
# Alias stuff | ||
#------------------------------ | ||
alias cp='cp -r' | ||
alias ls='ls -F' | ||
alias l='ls -Flha' | ||
alias rm='rm -r' | ||
alias ls='ls --color -F' | ||
alias lsd='ls -d *(/)' | ||
alias lsf='ls -h *(.)' | ||
|
||
#----------------- | ||
# Options | ||
#----------------- | ||
|
||
setopt AUTO_CD # implicate cd for non-commands | ||
setopt CORRECT_ALL # correct spelling | ||
setopt COMPLETE_IN_WORD # complete commands anywhere in the word | ||
setopt NOTIFY # Notify when jobs finish | ||
setopt BASH_AUTO_LIST # Autolist options on repeition of ambiguous args | ||
setopt AUTO_PUSHD # Push dirs into history | ||
setopt MULTIOS # Allow Multiple pipes | ||
setopt MAGIC_EQUAL_SUBST # Expand inside equals | ||
setopt EXTENDED_GLOB | ||
setopt NOBEEP | ||
setopt INC_APPEND_HISTORY | ||
export HISTSIZE=100000 | ||
export SAVEHIST=100000 | ||
export HISTFILE=~/.zhistory | ||
setopt hist_ignore_all_dups | ||
setopt hist_ignore_space | ||
|
||
export PATH=$HOME/.local/bin:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
REV=`git log -n 1 --pretty=format:%h -- docker/` | ||
IMGNAME="suricatta-devenv" | ||
|
||
function kill-container { | ||
echo "Cleaning development container $IMGNAME:$REV..." | ||
if $(docker ps | grep -q $IMGNAME); then | ||
docker ps | grep $IMGNAME | awk '{print $1}' | xargs --no-run-if-empty docker kill | ||
fi | ||
if $(docker ps -a | grep -q $IMGNAME); then | ||
docker ps -a | grep $IMGNAME | awk '{print $1}' | xargs --no-run-if-empty docker rm | ||
fi | ||
} | ||
|
||
function remove-image { | ||
echo "Clean old development image $IMGNAME..." | ||
docker images | grep $IMGNAME | awk '{print $3}' | xargs --no-run-if-empty docker rmi | ||
} | ||
|
||
function build-devenv { | ||
kill-container | ||
echo "Building development image $IMGNAME:$REV..." | ||
docker build --rm=true -t $IMGNAME:$REV -t $IMGNAME:latest --build-arg EXTERNAL_UID=$(id -u) docker/ | ||
} | ||
|
||
function reset { | ||
kill-container | ||
|
||
if ! $(docker images | grep $IMGNAME | grep -q $REV); then | ||
build-devenv | ||
fi | ||
} | ||
|
||
function docker-run { | ||
docker run --rm -ti \ | ||
-v `pwd`:/home/devuser/suricatta \ | ||
-v $HOME/.m2:/home/devuser/.m2 \ | ||
-w /home/devuser/suricatta \ | ||
$IMGNAME:latest $@ | ||
} | ||
|
||
|
||
function run-devenv { | ||
reset || exit -1; | ||
mkdir -p $HOME/.m2 | ||
docker-run /bin/zsh | ||
} | ||
|
||
function run-tests { | ||
reset || exit -1; | ||
docker-run clojure -Adev:test | ||
} | ||
|
||
function help { | ||
echo "suricatta devenv manager v$REV" | ||
echo "USAGE: $0 OPTION" | ||
echo "Options:" | ||
echo "- clean Kill container and remove image" | ||
echo "- build-devenv Build docker container for development" | ||
echo "- run-devenv Run (and build if necessary) development container" | ||
echo "- run-tests Execute unit tests for both backend and frontend" | ||
} | ||
|
||
case $1 in | ||
clean) | ||
kill-container | ||
remove-image | ||
;; | ||
build-devenv) | ||
build-devenv | ||
;; | ||
run-devenv) | ||
run-devenv | ||
;; | ||
run-tests) | ||
run-tests | ||
;; | ||
*) | ||
help | ||
;; | ||
esac |