Back to Moon

docker file

website/docs/commands/docker/file.mdx

2.2.42.4 KB
Original Source

import VersionLabel from '@site/src/components/Docs/VersionLabel';

<VersionLabel version="1.27.0" header />

The moon docker file <project> command can be used to generate a multi-staged Dockerfile for a project, that takes full advantage of Docker's layer caching, and is primarily for production deploys (this should not be used for development).

shell
$ moon docker file <project>

As mentioned above, the generated Dockerfile uses a multi-stage approach, where each stage is broken up into the following:

  • base - The base stage, which simply installs moon for a chosen Docker image. This stage requires Bash.
  • skeleton - Scaffolds workspace and sources repository skeletons using moon docker scaffold.
  • build - Copies required sources, installs the toolchain using moon docker setup, optionally builds the project, and optionally prunes the image using moon docker prune.
  • start - Runs the project after it has been built. This is typically starting an HTTP server, or executing a binary.

:::info

View the official Docker usage guide for a more in-depth example of how to utilize this command.

:::

Arguments

  • <id> - Name or alias of a project, as defined in projects.
  • [dest] - Destination to write the file, relative from the project root. Defaults to Dockerfile.

Options

  • --defaults - Use default options instead of prompting in the terminal.
  • --build-task - Name of a task to build the project. Defaults to the docker.file.buildTask setting, or prompts in the terminal.
  • --image - Base Docker image to use. Defaults to an image derived from the toolchain, or prompts in the terminal.
  • --no-prune - Do not prune dependencies in the build stage.
  • --no-setup - Do not setup dependencies in the build stage. <VersionLabel version="2.0.0" />
  • --no-toolchain - Do not use the toolchain and instead use system binaries.
  • --start-task - Name of a task to start the project. Defaults to the docker.file.startTask setting, or prompts in the terminal.
  • --template - Template path, relative from the workspace root, to render the Dockerfile with. <VersionLabel version="2.0.0" />

Configuration