Commit bb1f5bc9 authored by Kamil Trzciński's avatar Kamil Trzciński

Remove Docker containers before starting build

parent 44a84e07
v 0.1.6
- Remove Docker containers before starting job
v 0.1.5
- Added Parallels executor which can use snapshots for fast revert (only OSX supported)
- Refactored sources
......
......@@ -35,10 +35,10 @@ This project was made as Go learning opportunity. The initial release was create
1. Simply download one of this binaries for your system:
```bash
sudo wget -O /usr/local/bin/gitlab-ci-multi-runner https://github.com/ayufan/gitlab-ci-multi-runner/releases/download/v0.1.5/gitlab-ci-multi-runner-linux-386
sudo wget -O /usr/local/bin/gitlab-ci-multi-runner https://github.com/ayufan/gitlab-ci-multi-runner/releases/download/v0.1.5/gitlab-ci-multi-runner-linux-amd64
sudo wget -O /usr/local/bin/gitlab-ci-multi-runner https://github.com/ayufan/gitlab-ci-multi-runner/releases/download/v0.1.5/gitlab-ci-multi-runner-darwin-386
sudo wget -O /usr/local/bin/gitlab-ci-multi-runner https://github.com/ayufan/gitlab-ci-multi-runner/releases/download/v0.1.5/gitlab-ci-multi-runner-darwin-amd64
sudo wget -O /usr/local/bin/gitlab-ci-multi-runner https://github.com/ayufan/gitlab-ci-multi-runner/releases/download/v0.1.6/gitlab-ci-multi-runner-linux-386
sudo wget -O /usr/local/bin/gitlab-ci-multi-runner https://github.com/ayufan/gitlab-ci-multi-runner/releases/download/v0.1.6/gitlab-ci-multi-runner-linux-amd64
sudo wget -O /usr/local/bin/gitlab-ci-multi-runner https://github.com/ayufan/gitlab-ci-multi-runner/releases/download/v0.1.6/gitlab-ci-multi-runner-darwin-386
sudo wget -O /usr/local/bin/gitlab-ci-multi-runner https://github.com/ayufan/gitlab-ci-multi-runner/releases/download/v0.1.6/gitlab-ci-multi-runner-darwin-amd64
```
1. Give it permissions to execute:
......
......@@ -115,8 +115,13 @@ func (s *DockerExecutor) createService(service, version string) (*docker.Contain
return nil, err
}
containerName := s.Build.ProjectUniqueName() + "-" + service
// this will fail potentially some builds if there's name collision
s.removeContainer(containerName)
createContainerOpts := docker.CreateContainerOptions{
Name: s.Build.ProjectUniqueName() + "-" + service,
Name: containerName,
Config: &docker.Config{
Image: serviceImage.ID,
Env: s.Config.Environment,
......@@ -182,8 +187,13 @@ func (s *DockerExecutor) createContainer(image *docker.Image, cmd []string) (*do
hostname = s.Build.ProjectUniqueName()
}
containerName := s.Build.ProjectUniqueName()
// this will fail potentially some builds if there's name collision
s.removeContainer(containerName)
create_container_opts := docker.CreateContainerOptions{
Name: s.Build.ProjectUniqueName(),
Name: containerName,
Config: &docker.Config{
Hostname: hostname,
Image: image.ID,
......@@ -239,7 +249,7 @@ func (s *DockerExecutor) createContainer(image *docker.Image, cmd []string) (*do
return container, nil
}
func (s *DockerExecutor) removeContainer(id string) {
func (s *DockerExecutor) removeContainer(id string) error {
remove_container_opts := docker.RemoveContainerOptions{
ID: id,
RemoveVolumes: true,
......@@ -247,6 +257,7 @@ func (s *DockerExecutor) removeContainer(id string) {
}
err := s.client.RemoveContainer(remove_container_opts)
s.Debugln("Removed container", id, "with", err)
return err
}
func (s *DockerExecutor) Prepare(config *common.RunnerConfig, build *common.Build) error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment