Skip to content

Commit

Permalink
Setup docker
Browse files Browse the repository at this point in the history
  • Loading branch information
centerorbit committed Aug 5, 2018
1 parent 4cebfbc commit bc96937
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 22 deletions.
6 changes: 5 additions & 1 deletion .gitignore
@@ -1,3 +1,7 @@
.idea
depcharge
*.exe
*.exe

bin
pkg
src
57 changes: 57 additions & 0 deletions .gitlab-ci.yml
@@ -0,0 +1,57 @@
image: golang:1.10-alpine

stages:
- init
- test
- build

init:
stage: init
script:
- export GOPATH=$(pwd)
- apk update && apk add git
- go get github.com/ghodss/yaml github.com/cbroglie/mustache/... github.com/stretchr/testify
artifacts:
paths:
- bin/
- pkg/
- src/


test:
stage: test
dependencies:
- init
coverage: '/coverage: \d+\.\d+\%/'
script:
- export GOPATH=$(pwd)
- go test -cover


build:
stage: build
dependencies:
- init
script:
- export GOPATH=$(pwd)
- go build .
artifacts:
paths:
- depcharge


build-docker:
image: docker:latest
stage: build
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:latest .

# Ensure the container can run properly
- docker run $CI_REGISTRY_IMAGE:latest

- docker push $CI_REGISTRY_IMAGE:latest
only:
- master
23 changes: 23 additions & 0 deletions Dockerfile
@@ -0,0 +1,23 @@
FROM golang:1.10-alpine as go

RUN apk update \
&& apk add git \
&& rm -rf /var/cache/apk/*

RUN go get \
github.com/ghodss/yaml \
github.com/cbroglie/mustache/... \
github.com/stretchr/testify

COPY . /go/src/depcharge
WORKDIR /go/src/depcharge

RUN go test .
RUN go build .

FROM alpine:latest
COPY --from=go /go/src/depcharge/depcharge /bin/depcharge
RUN mkdir /mount
WORKDIR /mount
ENTRYPOINT ["depcharge"]
CMD ["--help"]
25 changes: 4 additions & 21 deletions README.md
Expand Up @@ -2,9 +2,6 @@

DepCharge is a tool designed to help orchestrate the execution of commands across many directories at once.

* [GitHub is the public-access repository](https://github.com/centerorbit/depcharge)
* [GitLab is where development & pipelines occur](https://gitlab.com/centerorbit/depcharge)

## Introduction
A medium-to-large sized project (especially when using a microservice architecture) will consist of 3 or more separate repositories, and rely on a variety of package managers depending on the various languages chosen for each service. Typically, these repos must be managed, tracked, and released in some semblance of unison so that the dependant service calls can be understood and responded to appropriately.

Expand Down Expand Up @@ -92,26 +89,12 @@ Will run `composer install` across any composer dependencies that have either th
And much more!


## ToDo:
### Before v1.0
* Setup sample project for example and test
* Build Pipeline

### Wish List
1. Test support of YAML anchors
2. Secrets managment?
3. docker-compose handler
4. Implement channels / goroutines
5. Mechanism to perform _other_ types of commands to 'kind's rather than `kind`
6. Need a "literal" flag, to turn off templating?
7. Find a way to "stream" output to terminal?
8. Test Coverage
9. Better Logging & Verbose flag


## Additional Resources
* https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree
* https://mustache.github.io/

## Contributing
* [GitLab is where development & pipelines occur](https://gitlab.com/centerorbit/depcharge)
* [GitHub is the public-access repository](https://github.com/centerorbit/depcharge)


## License
Expand Down
22 changes: 22 additions & 0 deletions actionHandler_test.go
@@ -0,0 +1,22 @@
package main

import (
"testing"
"github.com/stretchr/testify/assert"
"reflect"
)

func TestFindActionHandler(t *testing.T) {
var handler func([]Dep, Perform)

handler = findActionHandler("git")
functionEqual(t, gitActionHandler, handler)
handler = findActionHandler("secret")
functionEqual(t, secretesActionHandler, handler)
handler = findActionHandler("other")
functionEqual(t, defaultActionHandler, handler)
}

func functionEqual(t *testing.T, expected func([]Dep, Perform), actual func([]Dep, Perform)){
assert.Equal(t, reflect.ValueOf(expected), reflect.ValueOf(actual))
}
27 changes: 27 additions & 0 deletions dep.yml
@@ -0,0 +1,27 @@
deps:
- name: depcharge
kind: project
location: ./
deps:
- name: gitlab
kind: git
location:
params:
repo: git@gitlab.com:centerorbit/depcharge.git
- name: github
kind: git
location:
params:
repo: git@github.com:centerorbit/depcharge.git
- name: yaml-parser
kind: go
params:
get: github.com/ghodss/yaml
- name: mustache
kind: go
params:
get: github.com/cbroglie/mustache/...
- name: assertions
kind: go
params:
get: github.com/stretchr/testify
5 changes: 5 additions & 0 deletions docker/docker-entrypoint.sh
@@ -0,0 +1,5 @@
#!/bin/bash



exec "$@"

0 comments on commit bc96937

Please sign in to comment.