# 
---
Why Docker?
---

---

---
\: can we docker?
\: we have docker at home
---
docker at home:

---
### *Setup*
1. Get [Docker for Mac](https://store.docker.com/editions/community/docker-ce-desktop-mac)
```bash
brew cask install docker
open -a Docker.app
```
2. Clone Cyberbiz
```bash
git clone git@github.com:sinlead/cyberbiz.co.git
cd cyberbiz.cp
```
3. Install [docker-sync](https://github.com/EugenMayer/docker-sync):
```bash
gem install docker-sync
```
4. Invoke the setup script
```bash
./setup.sh
```
---
## `./setup.sh`
---

:thinking_face:
---
GitHub permissions babyyyyyyy

---
- `volumes: ~/.ssh:/root/.ssh`
- `volumes: /var/root/.ssh:/root/.ssh`
- `docker build . --build-arg SSH_PRIVATE_KEY="$(sudo cat /var/root/.ssh/id_rsa)"`
- secrets in docker-compose.yml
---
`ssh: Could not resolve hostname github.com-repo-hct-express: nodename nor servname provided, or not known`
---

- remove `CI=true` ?
---
Yiyang 
---
`bundle install`
---
`ERROR: CMake is required to build Rugged.`
---

---
wkhtmltox
`Invalid platform`
---

---

---
zbar
`Unable to find zbar shared library`
---
```yaml
- ZBAR_LIB=/usr/lib/aarch64-linux-gnu/libzbar.so.0
```
---
`variable sql_mode can't be set to the value of no_auto_create_user in MySQL 8.0`
---

---
rake assets:precompile` requires mysql connection
- run mysql server first, or
- `config.assets.initialize_on_precompile = false`
---
RAILS 5+
```
ActiveRecord::ProtectedEnvironmentError: You are
attemptingto run a destructive action against your
'production' database. If you are sure you want to
continue, run the same command with the environment
variable: DISABLE_DATABASE_ENVIRONMENT_CHECK=1
```
```bash
db:drop DISABLE_DATABASE_ENVIRONMENT_CHECK=1
```
---
some not-really-docker problem

---
`cp config/app_secret_config.yml`
---
db:migration
`Unknown column 'order_line_items.deleted_at' in 'where clause'`
```ruby
# In app/models/order_line_item.rb - add this temporarily
def self.reset_column_information
super
# Remove any default scopes during migrations
self.default_scopes = []
end
```
> Thanks to Alen Dong (TWD), Amazon Q
---
```
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
```
---
Gemfile.lock

---
`Unknown version XX of op_mob`
---
```bash
# frontend/shop/.browserlistrc:
not op_mob >= 1
```
---

---
`docker-sync-stack start`
---

---
`exited with code 137`
---

---
ASSET_FROM_REMOTE

but it's all or one
---
```bash
ASSET_FROM_REMOTE=shop bundle exec puma
ASSET_FROM_REMOTE=shop,checkout,pos bundle exec puma
ASSET_FROM_REMOTE=except:shop bundle exec puma
ASSET_FROM_REMOTE=except:shop,pos bundle exec puma
# also fixed some code
# - app/services/frontend/manifest.rb
# - app/concerns/shops/shop_app_path.rb
```
---
COMPOSE_PROFILES

```yaml
ASSET_FROM_REMOTE: except:${COMPOSE_PROFILES:-}
```
```bash
COMPOSE_PROFILES=shop docker-sync-stack start
COMPOSE_PROFILES=shop,pos docker-sync-stack start
docker-sync-stack start
```
---

---
rspec/cucumber
`cannot connect to mysql database / frontend server`
---
Add dev/test envs
- `config/app_config.yml`
- `config/database.yml.docker`
- `features/support/env.rb`
- allow `cdn.cybassets.com`
---
Are we there yet?
---
Time for a test build on a potato laptop
---

`yarn build exited with code 137`
---
we have remote assets anyways
---
Features
---
.env
```ini
ARCH=arm64 # $(uname -m)
ARM64=true # set to empty if not ARM64
WKHTMLTOX_ARCH=arm64 # one of amd64, arm64, i386, ppc64el
SSH_PRIVATE_KEY_PATH=/Users/your.name/.ssh/id_rsa # your github ssh private key path
SSH_CONFIG_PATH=/Users/your.name/.ssh/config # your github ssh config path
REPLICA_USERNAME=your.name # your database replica username
REPLICA_PASSWORD=yourpassword # your database replica password
# path to zbar library, you probably need it for ARM64
ZBAR_LIB=/usr/lib/aarch64-linux-gnu/libzbar.so.0
```
docker compose reads this.
---
- runs a rails shell
`docker-compose run --rm rails bash`
- runs a replica rails shell
`docker-compose run --rm replica bash`
---
Thanks!
{"title":"Docker","description":"Why docker?","contributors":"[{\"id\":\"316444af-23e0-4ddb-bfd1-69bb074068c7\",\"add\":7815,\"del\":2469,\"latestUpdatedAt\":1753344899789}]"}