Generates docker artifacts based on a ci.yml of a workspace
The generated artifacts will be saved in the output folder (default is ./export). It then generates following artifacts inside the output folder:
./ Each service is exported to a separate folder. .//dockerfile docker to build the container of the service. .//entrypoint.sh Entrypoint of the container (run stage of Codesphere workspace). ./docker-compose.yml Environment to allow running the services with docker-compose. ./nginx.conf Configuration for NGINX, which is used by as router between services.
Codesphere recommends adding the generated artifacts to the source code repository.
Limitations:
- Environment variables have to be set explicitly as the Codesphere environment has its own way to provide env variables.
- The workspace ID, team ID etc. are not automatically available and have to be set explicitly.
- Hardcoded workspace urls don't work outside of the Codesphere environment.
- Each dockerfile of your services contain all prepare steps. To have the smallest image possible you would have to delete all unused steps in each service.
cs generate docker [flags]
# Generate docker for workspace 1234
$ cs generate docker -w 1234
# Generate docker for workspace 1234 based on ci profile ci.prod.yml
$ cs generate docker -w 1234 -i ci.prod.yml
-b, --baseimage string Base image for the docker
-e, --env stringArray Env vars to put into generated artifacts
-h, --help help for docker
-a, --api string URL of Codesphere API (can also be CS_API)
--branch string Branch of the repository to clone if the input file is not found (default "main")
-f, --force Overwrite any files if existing
-i, --input string CI profile to use as input for generation, relative to repository root (default "ci.yml")
-o, --output string Output path of the folder including generated artifacts, relative to repository root (default "export")
--reporoot string root directory of the workspace repository to export. Will be used to clone the repository if it doesn't exist. (default "./workspace-repo")
-t, --team int Team ID (relevant for some commands, can also be CS_TEAM_ID) (default -1)
-v, --verbose Verbose output
-w, --workspace int Workspace ID (relevant for some commands, can also be CS_WORKSPACE_ID) (default -1)
- cs generate - Generate codesphere artifacts