--from options. This page contains a number of recipes
which you an add to an existing Dockerfile to incorporate content from outside
of the Dockerfile.
The way to do this is extremely simple. As an example, the following statements
will copy the contents of your current directory (recursively) into the image:
Versioning
The fix for this is simple. You change your base image. Find occurrences in your Dockerfile that look like:- nodesource: we can change
setup_current.xto specify the major node version, for examplesetup_18.xfor the current lts version. It isn’t possible with this technique to specify the minor or patch version. If this is important to you, chose one of the other three alternatives. - merging images: just as you can specify
FROM ruby:3.2.0-slimyou can specifyFROM node:18.13.0-slim. It is important to ensure that both images are based on the same operating system (e.g. debian vs alpine), and release (e.g. bullseye vs buster). To make things clearer and avoid problems, include the OS release in the name, for exampleruby:3.2.0-slim-bullseyeandnode:18.13.0-bullseye-slim. Yes, these two projects do order the parts to this name differently. - volta: specify the node version on the install, for
example:
volta install node@18.13.0. - node as base: specify the desired node version on the FROM line, but then use a Ruby version manager to install the desired version of Ruby.
dockerignore
WhileCOPY . . is effective, it is a bit too inclusive. For the same reason
that you have a .gitignore file you need a .dockerignore file: you don’t
want to deploy your tmp files, your test databases, your node_modules directory
or your master key.
If you don’t already have one, copy your .gitignore file.
Now run fly secrets list. If you don’t see RAILS_MASTER_KEY listed there make your
master key available to your deployment image by setting a secret. Mac and Linux
users can run the following command:
.dockerignore file and secret set by this point
as fly launch will do both for you.
binstubs
At this point you are including all of your source minus binaries, irrelevant files, and sensitive files. There still remains one set of files that aren’t binary, are very relevant, but may be platform specific: binstubs. These files start with a she bang, which on Windows machines may contain the letters.exe. And consist of multiple
lines where the line separator is \r on Windows vs \n on Linux. And on
Linux need to be marked executable in order to run.
For these reasons, Windows users may need lines like the following in their Dockerfile: