containers / build

another build tool for container images (archived, see https://github.com/rkt/rkt/issues/4024)
Apache License 2.0
342 stars 80 forks source link

.aci increases in size with each build #311

Closed jharshman closed 7 years ago

jharshman commented 7 years ago

AcBuild Version:

➜  ~ acbuild version
acbuild version v0.4.0
appc version 0.8.5

Given the following snippet:

# writeout aci
acbuild write --overwrite my-rbenv.aci

The generated .aci never seems to be actually overwritten, but instead increases in size. Example: first pass -

➜  ~ ./aci_build.sh
Beginning build with an empty ACI
[ ... snip ... ]
Ending the build
➜  ~ ls -lh my-rbenv.aci
-rw-r--r-- 1 root 209M May 30 15:17 my-rbenv.aci

second pass -

➜  ~ ./aci_build.sh
Beginning build with an empty ACI
[ ... snip ... ]
Ending the build
➜  ~ ls -lh my-rbenv.aci
-rw-r--r-- 1 root 415M May 30 15:23 my-rbenv.aci
cgonyeo commented 7 years ago

That's bizarre. Can you share the ./aci_build.sh script so I can see if the same thing happens on my machine?

jharshman commented 7 years ago
#!/usr/bin/env bash

set -e

if [ "$EUID" -ne 0 ]; then
  echo "needs root"
  exit 1
fi

acbuildend() {
  export EXIT=$?;
  acbuild --debug end && exit $EXIT;
}

acbuild --debug begin
trap acbuildend EXIT

acbuild set-name my-rbenv

acbuild dependency add quay.io/coreos/alpine-sh

acbuild run -- apk --update upgrade

acbuild run -- apk add --update \
  bash                          \
  git                           \
  curl                          \
  ruby-dev                      \
  readline-dev                  \
  openssl-dev                   \
  zlib-dev                      \
  libffi-dev                    \
  linux-headers                 \
  imagemagick-dev               \
  build-base                    \
  mysql-client                  \
  mysql-dev                     \
  ruby-io-console               \
  curl                          \
  ca-certificates               \
  ;

RBENV_ROOT=/usr/local/rbenv
RUBY_VERSION=2.3.3

acbuild environment add PATH $RBENV_ROOT/shims:$RBENV_ROOT/bin:$PATH

acbuild run -- git clone https://github.com/rbenv/rbenv.git $RBENV_ROOT
acbuild run -- git clone https://github.com/rbenv/ruby-build.git $RBENV_ROOT/plugins/ruby-build

# install ruby
acbuild run -- $RBENV_ROOT/plugins/ruby-build/install.sh
acbuild run -- $RBENV_ROOT/bin/rbenv install $RUBY_VERSION
acbuild run -- $RBENV_ROOT/bin/rbenv global $RUBY_VERSION

# install bundler
acbuild run -- gem install bundler --no-doc --no-ri

# copy source into container
acbuild copy-to-dir * /tmp/app/

# set working directory
acbuild set-working-directory /tmp/app/

# set entrypoint
acbuild set-exec -- ./runtests.sh --lint

# writeout aci
acbuild write --overwrite my-rbenv.aci
mcgoo commented 7 years ago

Are you copying the previously built aci into the new aci by any chance?

lucab commented 7 years ago
acbuild copy-to-dir * /tmp/app/

This seems problematic, as after the first run you are re-including my-rbenv.aci.

jharshman commented 7 years ago

ha! didn't even realize that was happening. Thanks!