mirror of https://github.com/perkeep/perkeep.git
Merge branch 'master' of https://camlistore.googlesource.com/camlistore
This commit is contained in:
commit
1e8a41595d
|
@ -33,47 +33,39 @@ var (
|
||||||
rev = flag.String("rev", "4e8413c5012c", "Camlistore revision to build (tag or commit hash")
|
rev = flag.String("rev", "4e8413c5012c", "Camlistore revision to build (tag or commit hash")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
// buildDockerImage builds a docker image from the Dockerfile located in
|
||||||
flag.Parse()
|
// imageDir, which is a path relative to dockDir. The image will be named after
|
||||||
if flag.NArg() != 0 {
|
// imageName. dockDir should have been set behorehand.
|
||||||
log.Fatalf("Bogus usage. dock does not currently take any arguments.")
|
func buildDockerImage(imageDir, imageName string) {
|
||||||
|
if dockDir == "" {
|
||||||
|
panic("dockDir should be set before calling buildDockerImage")
|
||||||
}
|
}
|
||||||
|
cmd := exec.Command("docker", "build", "-t", imageName, ".")
|
||||||
camDir, err := osutil.GoPackagePath("camlistore.org")
|
cmd.Dir = filepath.Join(dockDir, imageDir)
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error looking up camlistore.org dir: %v", err)
|
|
||||||
}
|
|
||||||
dockDir := filepath.Join(camDir, "misc", "docker")
|
|
||||||
|
|
||||||
cmd := exec.Command("docker", "build", "-t", "camlistore/go", ".")
|
|
||||||
cmd.Dir = filepath.Join(dockDir, "go")
|
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
log.Fatalf("Error building camlistore/go: %v", err)
|
log.Fatalf("Error building docker image %v: %v", imageName, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(mpl): build djpeg-static here, like camlistore/go
|
var dockDir string
|
||||||
// above (and prefix the -t value with "camlistore/")
|
|
||||||
// (And pull above into a func)
|
|
||||||
|
|
||||||
|
const (
|
||||||
|
goDockerImage = "camlistore/go"
|
||||||
|
djpegDockerImage = "camlistore/djpeg"
|
||||||
|
)
|
||||||
|
|
||||||
|
func genCamlistore(ctxDir string) {
|
||||||
repl := strings.NewReplacer(
|
repl := strings.NewReplacer(
|
||||||
"[[REV]]", *rev,
|
"[[REV]]", *rev,
|
||||||
)
|
)
|
||||||
|
|
||||||
// ctxDir is where we run "docker build" to produce the final
|
|
||||||
// "FROM scratch" Docker image.
|
|
||||||
ctxDir, err := ioutil.TempDir("", "camli-build")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
check(os.Mkdir(filepath.Join(ctxDir, "/camlistore.org"), 0755))
|
check(os.Mkdir(filepath.Join(ctxDir, "/camlistore.org"), 0755))
|
||||||
defer os.RemoveAll(ctxDir)
|
|
||||||
|
|
||||||
cmd = exec.Command("docker", "run",
|
cmd := exec.Command("docker", "run",
|
||||||
"--rm",
|
"--rm",
|
||||||
"--volume="+ctxDir+"/camlistore.org:/OUT",
|
"--volume="+ctxDir+"/camlistore.org:/OUT",
|
||||||
"camlistore/go", "/bin/bash", "-c", repl.Replace(`
|
goDockerImage, "/bin/bash", "-c", repl.Replace(`
|
||||||
|
|
||||||
# TODO(bradfitz,mpl): rewrite this shell into a Go program that's
|
# TODO(bradfitz,mpl): rewrite this shell into a Go program that's
|
||||||
# baked into the camlistore/go image, and then all this shell becomes:
|
# baked into the camlistore/go image, and then all this shell becomes:
|
||||||
|
@ -84,9 +76,9 @@ func main() {
|
||||||
set -x
|
set -x
|
||||||
export GOPATH=/gopath;
|
export GOPATH=/gopath;
|
||||||
export PATH=/usr/local/go/bin:$PATH;
|
export PATH=/usr/local/go/bin:$PATH;
|
||||||
mkdir -p /OUT/bin &&
|
mkdir -p /OUT/bin &&
|
||||||
mkdir -p /OUT/server/camlistored &&
|
mkdir -p /OUT/server/camlistored &&
|
||||||
mkdir -p /gopath/src/camlistore.org &&
|
mkdir -p /gopath/src/camlistore.org &&
|
||||||
cd /gopath/src/camlistore.org &&
|
cd /gopath/src/camlistore.org &&
|
||||||
curl --silent https://camlistore.googlesource.com/camlistore/+archive/[[REV]].tar.gz |
|
curl --silent https://camlistore.googlesource.com/camlistore/+archive/[[REV]].tar.gz |
|
||||||
tar -zxv &&
|
tar -zxv &&
|
||||||
|
@ -101,14 +93,30 @@ func main() {
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
log.Fatalf("Error building camlistored in go container: %v", err)
|
log.Fatalf("Error building camlistored in go container: %v", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func copyFinalDockerfile(ctxDir string) {
|
||||||
// Copy Dockerfile into the temp dir.
|
// Copy Dockerfile into the temp dir.
|
||||||
serverDockerFile, err := ioutil.ReadFile(filepath.Join(dockDir, "server", "Dockerfile"))
|
serverDockerFile, err := ioutil.ReadFile(filepath.Join(dockDir, "server", "Dockerfile"))
|
||||||
check(err)
|
check(err)
|
||||||
check(ioutil.WriteFile(filepath.Join(ctxDir, "Dockerfile"), serverDockerFile, 0644))
|
check(ioutil.WriteFile(filepath.Join(ctxDir, "Dockerfile"), serverDockerFile, 0644))
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(mpl): copy the djpeg out
|
func genDjpeg(ctxDir string) {
|
||||||
cmd = exec.Command("docker", "build", "-t", "camlistore/server", ".")
|
cmd := exec.Command("docker", "run",
|
||||||
|
"--rm",
|
||||||
|
"--volume="+ctxDir+":/OUT",
|
||||||
|
djpegDockerImage, "/bin/bash", "-c", "mkdir -p /OUT && cp /src/libjpeg-turbo-1.4.0/djpeg /OUT/djpeg")
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
log.Fatalf("Error building djpeg in go container: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildServer(ctxDir string) {
|
||||||
|
copyFinalDockerfile(ctxDir)
|
||||||
|
cmd := exec.Command("docker", "build", "-t", "camlistore/server", ".")
|
||||||
cmd.Dir = ctxDir
|
cmd.Dir = ctxDir
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
@ -117,6 +125,36 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
if flag.NArg() != 0 {
|
||||||
|
log.Fatalf("Bogus usage. dock does not currently take any arguments.")
|
||||||
|
}
|
||||||
|
|
||||||
|
camDir, err := osutil.GoPackagePath("camlistore.org")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error looking up camlistore.org dir: %v", err)
|
||||||
|
}
|
||||||
|
dockDir = filepath.Join(camDir, "misc", "docker")
|
||||||
|
|
||||||
|
buildDockerImage("go", goDockerImage)
|
||||||
|
buildDockerImage("djpeg-static", djpegDockerImage)
|
||||||
|
|
||||||
|
// ctxDir is where we run "docker build" to produce the final
|
||||||
|
// "FROM scratch" Docker image.
|
||||||
|
ctxDir, err := ioutil.TempDir("", "camli-build")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(ctxDir)
|
||||||
|
|
||||||
|
genCamlistore(ctxDir)
|
||||||
|
|
||||||
|
genDjpeg(ctxDir)
|
||||||
|
|
||||||
|
buildServer(ctxDir)
|
||||||
|
}
|
||||||
|
|
||||||
func check(err error) {
|
func check(err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
MAINTAINER Camlistore Contributors <camlistore@googlegroups.com>
|
MAINTAINER Camlistore Contributors <camlistore@googlegroups.com>
|
||||||
# TODO(mpl): uncomment the following line when dock.go builds it:
|
ADD djpeg /usr/bin/djpeg
|
||||||
# ADD djpeg /usr/bin/djpeg
|
|
||||||
ADD camlistore.org /camlistore
|
ADD camlistore.org /camlistore
|
||||||
|
|
||||||
EXPOSE 80 443
|
EXPOSE 80 443
|
||||||
|
|
|
@ -755,7 +755,7 @@ coreos:
|
||||||
[Service]
|
[Service]
|
||||||
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker
|
ExecStartPre=/usr/bin/docker run --rm -v /opt/bin:/opt/bin ibuildthecloud/systemd-docker
|
||||||
ExecStartPre=/bin/bash -c '/usr/bin/curl https://storage.googleapis.com/camlistore-release/docker/camlistored.tar.gz | /bin/gunzip -c | /usr/bin/docker load'
|
ExecStartPre=/bin/bash -c '/usr/bin/curl https://storage.googleapis.com/camlistore-release/docker/camlistored.tar.gz | /bin/gunzip -c | /usr/bin/docker load'
|
||||||
ExecStart=/opt/bin/systemd-docker run --rm -p 80:80 -p 443:443 --name %n -v /run/camjournald.sock:/run/camjournald.sock -v /var/lib/camlistore/tmp:/tmp --link=mysql.service:mysqldb camlistored
|
ExecStart=/opt/bin/systemd-docker run --rm -p 80:80 -p 443:443 --name %n -v /run/camjournald.sock:/run/camjournald.sock -v /var/lib/camlistore/tmp:/tmp --link=mysql.service:mysqldb camlistore/server
|
||||||
RestartSec=1s
|
RestartSec=1s
|
||||||
Restart=always
|
Restart=always
|
||||||
Type=notify
|
Type=notify
|
||||||
|
|
Loading…
Reference in New Issue