Containerizer
This is a simple and easy to use CLI to pack an application made with Angular and Express into a docker container.
What does it do?
Containerizer will first search for a package.json
and a containerizer.json
file in the current directory. Those files are used to provide autocomplete. It will then ask you a series of questions, which are documented below. The answers will be saved in the containerizer.json
file in the current working directory. It will then build a docker container on top of the tarampampam/node:12.14-alpine image. It will also bundle a few NodeJS scripts and the configuration.
Once you start the container using either your own or the generated docker-compose.yml
/ docker run
command, it will clone your GitHub repository and check out the required branch and commit. It will then install all the required dependencies, build your application and afterwards start it. During this installation process, a webserver is started on port 80, which serves a statuspage with information about the installation process. It looks like this:
If you change the environment variables, it will detect that and then rebuild the application.
How to use
- Install globally using
npm install containerizer --global
. - In the root folder of your Angular and Express App run
containerizer
. - Answer all the questions.
- Enjoy your Docker Image!
Update mechanism
Once your app is running, a http server on port 8314
will be avalible inside the container. By making a GET
request to http://localhost:8314
you will get a json string. When no updates are avalible, it will look like this:
Or, when updates are avalible, you will get something like this:
To start the update process, make a GET
request to http://localhost:8314/update
. When you get {success: true}
, your app will be killed and the update progress started. After a few seconds, the status server will take over port 80
and provide status information.
Roadmap
- 🔲 CLI Arguments
- 🔲 Update check script for releases mode
- 🔲 Updater for releases mode
- ✅ Update check script for commit mode
- ✅ Updater for commit mode
- ✅ Provide web server with status updates while installing (is implemented!)
- ✅ Fast update mode
Feel free to add more features with a pull request!
Basic container environment options
Name | Description | Default |
---|---|---|
baseHref | The path where the application will later be accessible. | / |
Config
Question | Name in config file | Description | Default | Example |
---|---|---|---|---|
Would you like to build the image with your last configuration loaded from containerizer.json ? |
n/a | Type y to skip all following questions and build using the containerizer.json file. |
No (n ) |
n/a |
Name of the image | imageName |
The name of the generated docker image | current foldername | MyCoolContainer |
Maintainer | imageMaintainer |
The full name of the maintainer of the generated docker image | Max Mustermann |
|
Username of Maintainer | imageMaintainerUsername |
The username of the maintainer of the generated docker image. This will be the scope for the image! | MMustermann |
|
Version | imageVersion |
The version of the maintainer of the generated docker image. | 1.0.0 |
4.2.19 |
Branch | branch |
The branch of the git repository to be checked out | master |
my-cool-branch |
Commit (leave blank to use latest) | commit |
The commit of the git repository to be checked out. Blank will be the latest commit. | a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 |
|
Git repository URL | repository |
The url of the git repository. | https://github.com/username/repository |
|
Source directory of Angular App | ngSrcDir |
The source directory of your Angular App relative to the root of your repository. | app/frontend/src/ |
|
Destination directory of Angular App | ngDestDir |
The destination directory of your Angular App after it was built relative to the root of your repository. | app/dist/frontend |
|
Custom Angular build command (empty for default) | customNgBuildCmd |
A custom build command to build the Angular App. | ng build |
|
The file to start in order to run the application | startFile |
The file to start to run the application. | /app/dist/api/app.js |
|
Directories to run "npm install" (separate with spaces) | npmInstallDirs |
Directories to run "npm install". Seperate them with spaces. In the config file this will be an array. | app/frontend app/backend |
|
Enable fast update mode | fastUpdateMode |
If enabled, updating will be faster but more diskspace will be used. Also unnecessaryFilesAndDirs will be ignored. |
y |
n/a |
Support native dependencies | supportNativeDependencies |
If enabled, python , make , g++ will be installed to make node-gyp work. Use it only when needed as it makes the image a lot bigger (additional 63 MB). |
n |
n/a |
Support image manipulation | supportImageManipulation |
If enabled, cairo-dev , jpeg-dev , pango-dev and giflib-dev will be installed. Use it only when needed as it makes the image bigger. |
n |
n/a |
Support Microsoft TrueTypeFonts | supportMicrosoftFonts |
If enabled, the Microsoft TTF core fonts will be installed. Use it only when needed as it makes the image bigger. | n |
n/a |
You can now edit the generated "containerizer.json" file to add filesToCreate, additionalBuilds and unnecessaryFilesAndDirs. Type in "Y" when you are done. | filesToCreate , additionalBuilds , unnecessaryFilesAndDirs |
See below | See below |
FilesToCreate
This property called filesToCreate
is an array of objects. Those state, which files should be created before running the build. Those can be used for dynamic values from the environment.
Example:
Templates:
Template name | Preview |
---|---|
typescript |
export const |
Feel free to add more templates and create a pull request!
AdditionalBuilds
This is an array of objects like this:
dir
points to the directory where cmd
should be run.
UnnecessaryFilesAndDirs
This is an array of files and/or folders which should be deleted after the successfull build to save disk space.
License
MIT