Skip to content

Commit

Permalink
Pull images from repo
Browse files Browse the repository at this point in the history
  • Loading branch information
80degreeswest committed May 26, 2020
1 parent 1b57e3c commit d3219e4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This repository hosts the [Buildfarm](https://github.com/bazelbuild/bazel-buildf
All commandline options override corresponding config settings.

```
./mvnw clean package && java -jar target/bfmgr-0.0.1.jar
./mvnw clean package && java -jar target/bfmgr-<REL NUMBER>.jar
```

Go to http://localhost:8080 and click Create.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.eightydegreeswest</groupId>
<artifactId>bfmgr</artifactId>
<version>0.0.1</version>
<version>0.0.2</version>
<name>bfmgr</name>
<description>Buildfarm Manager</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Value;

public class BfMgrCtrlLocal implements BfMgrCtrl {
Expand Down Expand Up @@ -59,6 +60,12 @@ public class BfMgrCtrlLocal implements BfMgrCtrl {
@Value("${remote.config.worker}")
private String remoteWorkerConfig;

@Value("${tag.redis}")
private String redisTag;

@Value("${tag.buildfarm}")
private String buildfarmTag;

@Override
public List<BuildfarmCluster> getBuildfarmClusters() throws UnknownHostException {
List<BuildfarmCluster> buildfarmClusters = new ArrayList<>();
Expand Down Expand Up @@ -105,6 +112,10 @@ public void createCluster(CreateClusterRequest createClusterRequest) throws IOEx
downloadFile(remoteWorkerConfig, Paths.get(configPath + "/shard-worker.config").toFile());
createPath(casPath);

pullImage(redisRepo, redisTag);
pullImage(serverRepo, buildfarmTag);
pullImage(workerRepo, buildfarmTag);

CreateContainerResponse response = dockerClient.createContainerCmd(redisRepo)
.withName(redisContainer)
.withPortSpecs("6379:6379")
Expand Down Expand Up @@ -160,4 +171,10 @@ private void downloadFile(String urlStr, File file) throws IOException {
fos.close();
rbc.close();
}

private void pullImage(String imageRepo, String tag) {
try {
dockerClient.pullImageCmd(imageRepo).withTag(tag).start().awaitCompletion(5, TimeUnit.MINUTES);
} catch (Exception e) { }
}
}
5 changes: 4 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ config.path=/tmp/buildfarm
cas.path=/tmp/worker

remote.config.server=https://raw.githubusercontent.com/bazelbuild/bazel-buildfarm/master/examples/shard-server.config.example
remote.config.worker=https://raw.githubusercontent.com/bazelbuild/bazel-buildfarm/master/examples/shard-worker.config.example
remote.config.worker=https://raw.githubusercontent.com/bazelbuild/bazel-buildfarm/master/examples/shard-worker.config.example

tag.redis=5.0.9
tag.buildfarm=latest

0 comments on commit d3219e4

Please sign in to comment.