Skip to content

Commit

Permalink
create rootfs/ and metadata.json
Browse files Browse the repository at this point in the history
[#112715265]

Signed-off-by: Corbin Halliwill <challiwill@pivotal.io>
  • Loading branch information
Robert Neumann authored and XenoPhex committed Feb 3, 2016
1 parent 4253c22 commit 980b6c9
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
assets/check
assets/print-metadata
bin/
tar-src/
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ RUN /usr/local/bin/docker --version

ADD assets/ /opt/resource/
RUN chmod +x /opt/resource/*

ADD bin/ /bin/
12 changes: 10 additions & 2 deletions assets/in
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ if [ "$skip_download" = "false" ]; then

docker save -o ${destination}/image "$image_name"

docker run \
--cidfile=/tmp/container.cid \
-v /opt/resource/print-metadata:/tmp/print-metadata \
"$image_name" \
/tmp/print-metadata > ${destination}/metadata.json

This comment has been minimized.

Copy link
@drnic

drnic Feb 24, 2016

Contributor

What is the metadata.json file for? Is it truly required to invoke docker run when doing an otherwise simple docker pull to get the image for a pipeline job?

For a postgresql-based docker image, we are seeing the following:

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
LOG:  database system was shut down at 2016-02-24 22:50:45 UTC
LOG:  MultiXact member wraparound protections are now enabled
FATAL:  the database system is starting up
psql: FATAL:  the database system is starting up
LOG:  autovacuum launcher started
LOG:  database system is ready to accept connections
NOTICE:  role "pgadmin" does not exist, skipping
LOG:  received fast shutdown request
LOG:  aborting any active transactions
LOG:  autovacuum launcher shutting down
LOG:  shutting down
LOG:  database system is shut down
LOG:  database system was shut down at 2016-02-24 22:51:00 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  autovacuum launcher started
LOG:  database system is ready to accept connections

and it is hanging here.

This comment has been minimized.

Copy link
@drnic

drnic Feb 24, 2016

Contributor

Ok, this was fixed in concourse 0.73.


mkdir -p ${destination}/rootfs/
docker export $(cat /tmp/container.cid) | tar -xf - -C ${destination}/rootfs/

if [ "$rootfs" = "true" ]; then
docker run --cidfile=container.cid "$image_name" echo container created
docker export $(cat container.cid) > ${destination}/rootfs.tar
docker export $(cat /tmp/container.cid) > ${destination}/rootfs.tar
fi
fi

Expand Down
18 changes: 17 additions & 1 deletion ci/scripts/build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

set -e -x

Expand All @@ -9,5 +9,21 @@ cd $(dirname $0)/../..
export GOPATH=$PWD/Godeps/_workspace:$GOPATH

go build -o ./assets/check ./cmd/check/
go build -o ./assets/print-metadata ./cmd/print-metadata/

if [ ! -e bin/tar ]; then
if [ ! -e tar-src ]; then
curl https://ftp.gnu.org/gnu/tar/tar-1.28.tar.gz | tar zxf -
mv tar-1.28 tar-src
fi

mkdir -p bin/

pushd tar-src/
FORCE_UNSAFE_CONFIGURE=1 ./configure
make LDFLAGS=-static
cp src/tar ../bin
popd
fi

cp -a ./* ${BUILT_RESOURCE}/
30 changes: 30 additions & 0 deletions cmd/print-metadata/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"encoding/json"
"os"
)

type imageMetadata struct {
Env []string `json:"env"`
}

var blacklistedEnv = map[string]bool{
"HOSTNAME": true,
}

func main() {
var envVars []string
for _, e := range os.Environ() {
if !blacklistedEnv[e] {
envVars = append(envVars, e)
}
}

err := json.NewEncoder(os.Stdout).Encode(imageMetadata{
Env: envVars,
})
if err != nil {
panic(err)
}
}

0 comments on commit 980b6c9

Please sign in to comment.