Skip to content
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

Closed
wants to merge 3 commits into from
Closed

Dockerized #11

wants to merge 3 commits into from

Conversation

centsent
Copy link

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 and mongodb 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 run go test.

dep

dep is a prototype dependency management tool for Go.
To use dep in the container, prefix make for all dep 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 of Database, if that is set, or "admin" otherwise.
Because we set the Database option in Config Object, so the authenticationDatabase argument was set to mongodm_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.

@centsent centsent mentioned this pull request Nov 10, 2017
@moehlone
Copy link
Contributor

moehlone commented Nov 16, 2017

LGTM! Thank you - I really like the approach with dep.
This weekend I will adjust the readme and contribution file within this pull request and then we are fine. Afterwards I would continue with automatically CI testing and I think the license should change to MIT. (@s3cc0 your license opinion?)

@moehlone
Copy link
Contributor

Haven`t forgotten this. Just zero time, sorry!

@uzarubin
Copy link
Contributor

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.

@centsent
Copy link
Author

centsent commented Jan 12, 2018

Agree. Sorry I won't submit another commit to this PR, the latest Dockerfile as below, please review it, it works for me.

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

image

@moehlone
Copy link
Contributor

moehlone commented Feb 7, 2018

@centsent @uzarubin I moved this to #14 - see information there :)

@moehlone moehlone closed this Feb 7, 2018
moehlone added a commit that referenced this pull request Feb 7, 2018
moehlone added a commit that referenced this pull request Feb 7, 2018
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants