-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerized #11
Dockerized #11
Conversation
LGTM! Thank you - I really like the approach with dep. |
Haven`t forgotten this. Just zero time, sorry! |
I would strongly encourage using the alpine docker containers for testing. Not only would it make CI faster since it won't have to download a larger docker image...it would be faster for people to run the test suite locally. |
Agree. Sorry I won't submit another commit to this PR, the latest FROM alpine
ENV GOPATH /go
ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin
ENV APP_DIR $GOPATH/src/mongodm
RUN apk add --no-cache --update go git libc-dev && \
mkdir -p $APP_DIR && \
go get -u github.com/golang/dep/cmd/dep && \
apk del git
ADD . $APP_DIR
WORKDIR $APP_DIR |
…isCI (#14) * chore: dockerized and use dep to manage dependencies * fix: add 'Source' option to Config * rebase mixed code * chore: Use golang:alpine image to shrink final size * feat: Add travis.yml * chore: Use native go environment * fix: Add mongodb for travis * fix: switch back to docker-compose for travis * Update readme for #11 * chore: Add TravisCI badge
This PR include two commits, one for dockerized, and the other one fix the
authenticationDatabase
problem.Dockerized
With docker, you do not need to install
go
andmongodb
on your local machine, it's easy to setup development environment for this repository.Prerequisites
Make sure you already installed below programs on your local machine:
git
docker
docker-compose
Usage
Just run
make test
, it will build the docker container and rungo test
.dep
dep is a prototype dependency management tool for Go.
To use
dep
in the container, prefixmake
for alldep
commands, for example:$ make dep "ensure -add github.com/some/repos"
Beware that the double quotes are required after
make dep
command.Authentication problem (Optional)
According to mgo DialInfo documents, the option
Source
is the database used to establish credentials and privileges with a MongoDB server. Defaults to the value ofDatabase
, if that is set, or "admin" otherwise.Because we set the
Database
option inConfig
Object, so theauthenticationDatabase
argument was set tomongodm_test
that could not connect to mongodb server correctly.The second commit solved this problem, it's optional to merge, but I think it's better to fully support options of
DialInfo
.