Skip to content

Instantly share code, notes, and snippets.

@RyanJarv
Last active November 24, 2020 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanJarv/2781b15e383b4d1b36daa40cf3d5268a to your computer and use it in GitHub Desktop.
Save RyanJarv/2781b15e383b4d1b36daa40cf3d5268a to your computer and use it in GitHub Desktop.
Example of msh building and running dockerfiles

Echo Example

% cat echo.msh                              
#!/usr/local/bin/msh exec docker build -t {{.Name}} -f {{.Path}} {{.ContextDir}}; docker run {{.Name}} hello world
FROM alpine:3
ENTRYPOINT ["echo"]
% ./echo.msh                               
2020/11/23 22:31:12 Running command and waiting for it to finish...
[+] Building 0.0s (5/5) FINISHED                                                                                                                                                               
 => [internal] load build definition from echo.msh                                                                                                                                            
 => => transferring dockerfile: 191B                                                                                                                                                          
 => [internal] load .dockerignore                                                                                                                                                             
 => => transferring context: 2B                                                                                                                                                               
 => [internal] load metadata for docker.io/library/alpine:3                                                                                                                                   
 => CACHED [1/1] FROM docker.io/library/alpine:3                                                                                                                                              
 => exporting to image                                                                                                                                                                        
 => => exporting layers                                                                                                                                                                       
 => => writing image sha256:595b26ac4285e518a9794f0f8287d6a3fb2df9dfeb636d11a9ca5fd8070424b4                                                                                                  
 => => naming to docker.io/library/echo.msh                                                                                                                                                   
2020/11/23 22:31:12 Running command and waiting for it to finish...
hello world

Cat Example

The dockerfile arg is mostly doing the same thing as the shebang line in the echo example. The idea is the syntax would be closer to this example but could be written out manually as well if you needed to.

% cat cat.msh                               
#!/usr/local/bin/msh dockerfile
FROM alpine:3
ENTRYPOINT ["cat"]
% echo 'hello world again'| ./cat.msh                               
2020/11/23 22:31:43 Running command and waiting for it to finish...
[+] Building 0.0s (5/5) FINISHED                                                                                                                                                               
 => [internal] load build definition from cat.msh                                                                                                                                             
 => => transferring dockerfile: 104B                                                                                                                                                          
 => [internal] load .dockerignore                                                                                                                                                             
 => => transferring context: 2B                                                                                                                                                               
 => [internal] load metadata for docker.io/library/alpine:3                                                                                                                                   
 => CACHED [1/1] FROM docker.io/library/alpine:3                                                                                                                                              
 => exporting to image                                                                                                                                                                        
 => => exporting layers                                                                                                                                                                       
 => => writing image sha256:a71009c164801bcd6572e22ca1c86da33a90dcb78c1b75c1187f74d62e0eb8a6                                                                                                  
 => => naming to docker.io/library/cat.msh                                                                                                                                                    
2020/11/23 22:31:43 Running command and waiting for it to finish...
hello world again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment