Skip to content

Commit

Permalink
Linux: use awscli instead of s3cmd to release
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Feb 5, 2021
1 parent 2323dca commit 16f8e5a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 32 deletions.
2 changes: 1 addition & 1 deletion linux/Rakefile
Expand Up @@ -102,7 +102,7 @@ ARCHITECTURES.each do |arch|

desc "Upload Ruby #{ruby_version} #{arch} packages to the server"
task "upload:#{ruby_version}:#{arch}" => [package, "#{gem_dir}/ok"] do
sh "./upload #{package} #{gem_dir}"
sh "env IMAGE_VERSION=#{IMAGE_VERSION} ./upload #{package} #{gem_dir}"
end

desc "Clean Ruby #{ruby_version} packages"
Expand Down
2 changes: 1 addition & 1 deletion linux/build-ruby
Expand Up @@ -26,7 +26,7 @@ function usage()
echo "Build Traveling Ruby binaries."
echo
echo "Options:"
echo " -i IMAGE Docker image to use (e.g. phusion/traveling-ruby-builder-x64_64:1.0)"
echo " -i IMAGE Docker image to use (e.g. phusion/traveling-ruby-builder-x86_64:1.0)"
echo " -r VERSION Ruby version to build. Default: $RUBY_VERSION"
echo " -c DIR Cache directory to use"
echo
Expand Down
1 change: 1 addition & 0 deletions linux/image/install.sh
Expand Up @@ -20,6 +20,7 @@ echo "$ARCHITECTURE" > /ARCHITECTURE
run yum install -y wget sudo readline-devel ncurses-devel s3cmd
run mkdir -p /ccache
run create_user app "App" 1000
run pip install awscli==1.19.2


### MySQL
Expand Down
5 changes: 5 additions & 0 deletions linux/internal/awsconfigure
@@ -0,0 +1,5 @@
#!/bin/bash
set -e
/hbb/bin/setuser app aws configure
cp -dpR ~app/.aws /work/awscfg
chown "$APP_UID:$APP_GID" /work/awscfg
5 changes: 5 additions & 0 deletions linux/internal/awsinit
@@ -0,0 +1,5 @@
#!/bin/bash
set -e
cp -r /awscfg /root/.aws
chown -R root: /root/.aws
exec "$@"
4 changes: 0 additions & 4 deletions linux/internal/s3configure

This file was deleted.

4 changes: 0 additions & 4 deletions linux/internal/s3init

This file was deleted.

48 changes: 26 additions & 22 deletions linux/upload
Expand Up @@ -20,17 +20,23 @@ if [[ $# == 0 ]]; then
exit 1
fi

if [[ ! -e ~/.s3cfg ]]; then
echo "~/.s3cfg doesn't exist; configuring one..."
if [[ "$IMAGE_VERSION" = "" ]]; then
echo "ERROR: please set the IMAGE_VERSION environment variable."
exit 1
fi

if [[ ! -e ~/.aws ]]; then
echo "~/.aws doesn't exist; configuring one..."
TEMPDIR=`mktemp -d /tmp/traveling-ruby.XXXXXXXX`
touch "$TEMPDIR/s3cfg"
docker run --rm -t -i \
docker run --rm -t -i --init \
-v "$SELFDIR/internal:/system:ro" \
-v "$TEMPDIR:/work" \
phusion/traveling-ruby-builder \
/system/my_init --quiet --skip-runit --skip-startup-files -- \
/system/s3configure
cp "$TEMPDIR/s3cfg" ~/.s3cfg
-e "APP_UID=$(id -u)" \
-e "APP_GID=$(id -u)" \
"phusion/traveling-ruby-builder-x86_64:$IMAGE_VERSION" \
/system/awsconfigure
mkdir ~/.aws
cp -pR "$TEMPDIR/awscfg"/* ~/.aws/
rm -rf "$TEMPDIR"
TEMPDIR=
echo
Expand All @@ -42,7 +48,7 @@ DIR_BASENAMES=()
for F in "$@"; do
BASENAME="`basename \"$F\"`"
F="`absolute_path \"$F\"`"

MOUNTS+=(-v "$F:/$BASENAME:ro")
if [[ -f "$F" ]]; then
FILE_BASENAMES+=("$BASENAME")
Expand All @@ -52,26 +58,24 @@ for F in "$@"; do
done

header "Uploading `echo ${FILE_BASENAMES[@]}` to Amazon S3..."
S3CFG="`echo ~/.s3cfg`"
AWSCFG="`echo ~/.aws`"

docker run --rm -t -i \
docker run --rm -t -i --init \
"${MOUNTS[@]}" \
-v "$S3CFG:/s3cfg:ro" \
-v "$AWSCFG:/awscfg:ro" \
-v "$SELFDIR/internal:/system:ro" \
phusion/traveling-ruby-builder \
/system/my_init --quiet --skip-runit --skip-startup-files -- \
/system/s3init \
s3cmd -P sync --no-preserve "${FILE_BASENAMES[@]}" s3://traveling-ruby/releases/
"phusion/traveling-ruby-builder-x86_64:$IMAGE_VERSION" \
/system/awsinit \
aws s3 cp "${FILE_BASENAMES[@]}" s3://traveling-ruby/releases/ --acl public-read

for DIR_BASENAME in "${DIR_BASENAMES[@]}"; do
echo
header "Uploading $DIR_BASENAME to Amazon S3..."
docker run --rm -t -i \
docker run --rm -t -i --init \
"${MOUNTS[@]}" \
-v "$S3CFG:/s3cfg:ro" \
-v "$AWSCFG:/awscfg:ro" \
-v "$SELFDIR/internal:/system:ro" \
phusion/traveling-ruby-builder \
/system/my_init --quiet --skip-runit --skip-startup-files -- \
/system/s3init \
s3cmd -P --delete-removed --no-preserve sync "$DIR_BASENAME/" "s3://traveling-ruby/releases/$DIR_BASENAME/"
"phusion/traveling-ruby-builder-x86_64:$IMAGE_VERSION" \
/system/awsinit \
aws s3 sync "$DIR_BASENAME" "s3://traveling-ruby/releases/$DIR_BASENAME/" --acl public-read --delete
done

0 comments on commit 16f8e5a

Please sign in to comment.