Skip to content

Commit

Permalink
feat(test): Add testing with Docker
Browse files Browse the repository at this point in the history
Closes: #4
  • Loading branch information
Derek Michael Frank committed Oct 15, 2016
1 parent 3fcbaa8 commit 0ab5c0c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*~
.DS_Store
.git/
.gitignore
venv*/
*/.git/
*/.gitignore
*/venv*/
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM alpine:3.4

MAINTAINER Derek M. Frank <derekmfrank at gmail dot com>

USER root

# Install dependencies.
RUN apk update && apk add \
bash \
git \
zsh

# Add user.
ENV HOME "/home/dot"
ENV SHELL "/bin/zsh"
ENV USER dot
RUN adduser -h $HOME -s "$SHELL" -S -D "$USER"

# Setup app.
ENV DOTFILES "$HOME/.dotfiles"
WORKDIR "$DOTFILES"
COPY . "$DOTFILES"
RUN chown -R "$USER" "$DOTFILES"

USER "$USER"
ENTRYPOINT ["./test/entrypoint.sh"]
CMD ["docker"]
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ defaults, and so on. Tweak this script, and occasionally run `dot` from
time to time to keep your environment fresh and up-to-date. You can find
this script in `bin/`.

## test

Because you don't want to necessarily ruin your local environment
everytime you make a change, let's use Docker.

**Note:** you can only test the pieces of your dotfiles that will work
in a Linux environment. macOS specifics cannot be tested.

### dependencies

#### docker

Be sure Docker is installed.

##### macOS

brew cask install docker

### run

./test/run.sh

## bugs

I want this to work for everyone; that means when you clone it down it should
Expand Down
20 changes: 20 additions & 0 deletions test/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

cd "$(dirname "$0")/.."
source 'script/bootstrap'

NAME="$(uname -s)"
RELEASE="$(uname -r)"

if ([[ "$RELEASE" = *'boot2docker' ]] || [[ "$RELEASE" = *'moby' ]]) && \
[[ "$1" = 'docker' ]] ; then
echo
echo 'You are using docker!'
echo 'I will assume bootstrap is being run as an entrypoint...'
echo

if [[ "$SHELL" != *'zsh' ]]; then
SHELL="$(which zsh)"
fi
exec "$SHELL" -li
fi

0 comments on commit 0ab5c0c

Please sign in to comment.