更新:我已将[或?]问题缩小到CGFloat
词典中的import Foundation
import CoreGraphics
let value1: CGFloat = -0.4
let value2: CGFloat = -0.5
let value3: CGFloat = -1
let value4: CGFloat = 0.4
let value5: CGFloat = 0.5
let value6: CGFloat = 1
let formatter = NumberFormatter()
formatter.numberStyle = NumberFormatter.Style.decimal
formatter.roundingMode = NumberFormatter.RoundingMode.ceiling
formatter.maximumFractionDigits = 0
let roundedValue1 = formatter.string(for: value1)
let roundedValue2 = formatter.string(for: value2)
let roundedValue3 = formatter.string(for: value3)
let roundedValue4 = formatter.string(for: value4)
let roundedValue5 = formatter.string(for: value5)
let roundedValue6 = formatter.string(for: value6)
print(String(describing: roundedValue1)) // prints Optional("-0")
print(String(describing: roundedValue2)) // prints Optional("-0")
print(String(describing: roundedValue3)) // prints Optional("-1")
print(String(describing: roundedValue4)) // prints Optional("1")
print(String(describing: roundedValue5)) // prints Optional("1")
print(String(describing: roundedValue6)) // prints Optional("1")
行。如果我删除它,容器运行正常[我认为]但可能我丢失了我的本地宝石缓存。
tldr:运行docker-compose构建后,事情似乎没问题,但如果我在运行的docker容器中运行任何 - groupy-gemcache:/usr/local/bundle
或services: app: volumes
的Gemfile。例如,在gem
之后:
bundle
我仍然是Docker的新手,但我一直在尝试配置一个完美的dockerfile,可以构建,缓存gems和更新,同时仍然将其Gemfile.lock提交给git [也许这实际上并不完美而且我我愿意接受那些建议。在我的用例中,我正在使用一个docker compose文件,其中包含rails应用程序和sidekiq worker以及postgres和redis图像的图像 - 非常类似于here和here所描述的设置。
我的Dockerfile [有些事情评论说我从上面的教程中拼凑出来:
docker-compose build && docker-compose run app bash
搬运工-compose.yml:
root@2ea58aff612e:/src# bundle check
The Gemfile's dependencies are satisfied
root@2ea58aff612e:/src# echo 'gem "hello-world"' >> Gemfile
root@2ea58aff612e:/src# bundle
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
root@2ea58aff612e:/src# bundle install
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
root@2ea58aff612e:/src# gem
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
root@2ea58aff612e:/src# gem env
Could not find gem 'hello-world' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
答案 0 :(得分:0)
我认为ENTRYPOINT ["bundle", "exec"]
与CMD ["./script/start.sh"]
或docker-compose run app bash
的结果是运行bundle exec 'bash'
之类的命令。我通过从dockerfile中删除入口点,如上所述进入shell并手动运行bundle exec 'bash'
来确认这一点,并且确定我已经落入子shell中,我无法运行任何bundle或gem命令 - 必须{{1}两次离开。