Attachment @ Docker howto file_download
2019-03-05
2019
03-05
«rails-cassamgr.sh»
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# https://ownyourbits.com/2018/06/27/running-and-building-arm-docker-containers-in-x86/
apt-get install qemu-user-static

docker run \
  -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static \
  -e LANG=en_US.utf8 -ti --name cassamgr arm32v7/debian:wheezy
--------------------------------------------------------------------------------
apt-get update

apt-get install -y dialog locales localepurge
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

apt-get install -y nano less screen ncdu sudo wget procps adduser ruby1.8 rubygems1.8 sqlite3 libsqlite3-dev

localepurge -v

rm -rf /var/lib/apt/lists/*

adduser cloud # pass: sagra
#echo "cloud ALL=NOPASSWD: ALL" > /etc/sudoers.d/local_users

sudo -u cloud bash -il
echo -e "install: --no-rdoc --no-ri --user-install\nupdate: --no-rdoc --no-ri --user-install" > ~/.gemrc
echo -e "PATH=\$HOME/.gem/ruby/1.8/bin:\$PATH\nexport PATH" >> ~/.bashrc
exit

sudo -u cloud bash -il
gem install bundler -v 1.17.3
cd [app_path]
bundle install --path=~/.gem
exit

REALLY_GEM_UPDATE_SYSTEM=yes gem update --system 1.3.2

sudo -u cloud bash -il
gem sources -a https://rubygems.org/
gem sources -r http://gems.rubyforge.org/

cd [app_path]
rake db:create:all
# PRAGMA schema.synchronous = FULL; -- do not use with an UPS
# PRAGMA journal_mode=WAL;          -- use DELETE to turn off
# PRAGMA wal_checkpoint(FULL);      -- flush now WAL to main DB
for i in *.sqlite3; do sqlite3 $i "PRAGMA journal_mode=WAL;"; done

exit

ncdu / # delete cache files
--------------------------------------------------------------------------------
docker commit cassamgr cassamgr

docker container prune -f

docker run \
  -v /usr/bin/qemu-arm-static:/usr/bin/qemu-arm-static \
  -v ~/gits/cassamgr_rails:/home/cloud/cassamgr \
  -e LANG=en_US.utf8 -ti --rm --name cassamgr \
  -u cloud -w /home/cloud/cassamgr -p 80:3000 \
  cassamgr /bin/bash -ilc "thin -e production start"

# run a command in a running container
docker exec -ti cassamgr bash -il

docker stop cassamgr
docker kill cassamgr