botanicus / docker-project-manager Goto Github PK
View Code? Open in Web Editor NEWQuickly spin off Docker containers for prototyping and development with your full dev environment, dotfiles and tools of choice.
License: MIT License
Quickly spin off Docker containers for prototyping and development with your full dev environment, dotfiles and tools of choice.
License: MIT License
docker-project-manager install
should get .bashrc
from https://github.com/botanicus/dev/issues/4
After that, recreate the env for DPM and add pre-commit
hook to run crystal tool format
in it.
First though we have to implement #21
Extracting .dotfiles.git
as a volume allows us to persist ~/.zsh/ignored.zsh
.
From #6: docker-project-manager write-alias
to add alias dpm="docker run -it --rm botanicus/docker-project-manager"
into .bashrc
.
First do #17.
I'm a freelancer. Many projects I do are short-term. Hence I need to spin off VM-like machines quickly with all my dotfiles and tools of choice installed.
After that, recreate the env for DPM and add pre-commit
hook to run crystal tool format
in it.
Generated key:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0atg7Mea0QZSvjSjwgfY
wyql+UfK3RdvoGRqI6ihj6SoF92njEvVfTxMUGASFU229Zt5CpSiXCqEy6ZOYQkK
MZV7SsoInToEgLGp3X05tddFmWr4A5IAP/TQWmVogc9RfWdYvZtIIQCP254nuOee
vLTzvmeq+kcGxAXqGrKbaWX6vfdA0MOViL9naxUY7ezn5FZh6uF3HMiFWf4WiRq6
TJZEgVE2aWVJ5Y5Ptx/MP1KWf0YFpHfvTNPhTiRx4yhUOrxVNiGw17Qs9mC6YbRk
kG7ZbFa/aK/yOhTfdDlKfxkNKuCN7u+yLycUSftraygt3Ibi3yYy8H8WeRIWfXTq
eQIDAQAB
-----END PUBLIC KEY-----
An example of a valid public key:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC3PftpccsW8mBhLxdd+I70XzVJ1saoyzzrgOR/EkV9fS+RH12x/vNUW3i5aBVxRUipnZwGd3uhFlnlaNDvQAkfQN0ea81C9BVrb6WodvDHcGjfVPMF7UOgeVInpa+w+vpdWVqi8SJjun0fv7GV2NzY8WVzD0UegtG0yvKVOY3kmvKnUlrsrtSXgZunONeWFxG68B9wS1tUqslcc8Nfz1fca+0o5TMAwf7oHVQ4gz/KSRRW0bMtXeF3N2cuYeV+r6vwc5gCV9UqaE+PzbxKRlr5AqHPuh2JxlhObM/aggUnfXNdpQ5BXQSHIh0It9i0tvP4NsDrZ7+kYSvB8LdX3DYZKFdUmxojys5JWy6i5AzFP1vG0YyVTD7Vk6sDRFKFO1bUM5puLM7DvLndxkLz72kv8UcSzGtqRHdYQM2ZHO2b/Pm7anf+4TeEC5usDdLnaOT4I3uAAhLaQfMb+XweM1NyLaMRzepoGGoS+yj1ZHdGG1TipxXk8xI+Q/AXMOYHZjyzmUtDffOEU/KCI++NKCqmmNJKlkkD3SpLjv3+tDYeYHP9E6SiSTKhEQ45k1+fxxsCSZ+EU7ow+3sY9fSiciKRaXbfmoe/q00ZHQapY9ePbVIDQUJOKxmD0mNINPXD+4WnCpVFcQACQ+46Ah8A2FsFRcVlr09hq0mLf1U3rYVtPQ== botanicus@ipad
According to StackExchange, it can be converted thus:
ssh-keygen -f private.pem -y > private.pub
The code: src/ssh-key-pair.cr
class Object
macro methods
{{ @type.methods.map &.name.stringify }}
end
end
puts Bool.methods
Then initiate in my dotfiles.
This probably will just be a section in README, but it'd be handy to be able to copy & paste from somewhere:
apt install -y zsh
echo $(which zsh) && chsh -s $(which zsh)
wget https://raw.githubusercontent.com/botanicus/dotfiles/master/.zsh/host.zsh -O ~/.zshrc
We want to preserve ZSH history between docker rm
/docker create
cycles.
The top-level manager #6 can work in 2 ways:
Either it prints it commands that are then piped to the host OS shell (that all is probably wrapped into a helper). This is OK to start, but at the end of the day, it'd be great if the manager could execute the commands directly.
The issue is that it's hard to install docker in BusyBox. BusyBox doesn't have a package manager. I can imagine a lot of tools would be missing for compilation. I wonder whether it's possible to build a statically-linked docker
binary and copy it just as we copy the binary we build from the Crystal source.
Probably the easiest solution is to derive the final image from https://hub.docker.com/_/docker
My idea is that pushing a new git tag will create a tag on DockerHub.
https://stackoverflow.com/questions/25328166/docker-hub-automated-build-tagging
Locally unit tests run (through docker build
) just fine.
On Travis it fails though.
I temporarily commented out that line.
crystal spec
in Dockerfile
.This will parse Dockerfile
and run docker create
with all the ports and volumes.
See #8
The manager could have access to $HOME
and each component would have it's own $HOME
-like directory:
riffr/README.md
riffr/Dockerfile (effectively contains the recipe of the project)
riffr/docker-compose.yml (optional)
riffr/.ssh/id_rsa
riffr/.ssh/id_rsa.pub
riffr/.history
riffr/.dotfiles.git
riffr/riffr (the actual repo)
Insulating .dotfiles.git
allows us to use ~/.zsh/ignored.zsh
that we don't want to share across projects.
These Dockerfile
's are private, never to be pushed to DockerHub. For instance:
FROM botanicus/dev:latest
ENV DROPBOX_ACCESS_TOKEN=xyz
EXPOSE 3000
VOLUME
Since EXPOSE
doesn't publish anything by itself, the manager should parse the Dockerfile
, take the exposed ports and convert them to "<port>:<port>"
form for the docker create
command.
The same goes for VOLUME
. One cannot specify host directory in Dockerfile
. So the manager should scan the Dockerfile and convert all VOLUME
entries into "<project-name>/<volume>:<volume>"
.
Considerations: Maybe I could just use this pseudo-home directory as the only volume? -v ~/riffr:/root
?
In ~/.zsh/setup.zsh
:
docker login -u botanicus -p $DOCKER_PASSWORD
Add to 1Password.
First, polish the documentation, add diagrams etc, so it's easy to understand how it works.
Without depending on ssh-keygen
.
Apparently it's possible in Ruby.
Which will be a shortcut for: stop
, remove
, build
, create
and start
.
Well, as of now without start
, since create
doesn't really create anything just yet: create a follow-up ticket.
To create a tmux session or attach to the running one.
Maybe it can be named sys as there's no sys sys really.
Default: mount ~/.ssh
as a volume.
Override: generate a new SSH key and pass it as an ENV variable.
This way we don't have to do IdentityFile ~/.ssh/jcrussell_gitlab_com
etc if one has multiple GitLab accounts.
The disadvantage may be, that the key gets recreated every time we recreate image with docker rm
.
We could create a new SSH dir and mount that one to /root/.ssh
, but I'm not fond of such approach.
Also we could just pass all the SSH keys as ENV variables, I think it's reasonable, the only thing is we'd have to mount ~/.ssh
for the docker-project-manager
to run.
Alternatively we can use simple Dockerfile
s as:
FROM botanicus/dev:latest
RUN ssh-keygen -t rsa
Then the SSH key would be cached (or not?)
After #15.
So the container really feels like a VM.
Even better, can I run it as a SSH server https://docs.docker.com/engine/examples/running_ssh_service/, expose the port and then add entries directly to Blink, so the containers look like a VM?
Currently ~/.zsh/tmux-auto-connect.zsh doesn't work. With this, it'd start working again.
Useful when a new VM is created:
This will take download everything from Projects/vps
in Dropbox and saves it as projects
.
dpm dropbox-download Projects/vps projects
dpm dropbox-upload projects Projects/vps
This will take everything in projects/
and upload it to Projects/vps
, (replacing what's already there?).
There is no Crystal Dropbox library.
Apart from Dockerfile
and README.md
, we need a script that makes it easier to manager containers.
This should be the primary interface to DPM after a project is initialized.
cd ~/projects/docker-project-manager
rake create
rake attach
rake rebuild
Add pre-commit hook to run crystal tool format in it.
(Add to the dev env and also to the Dockerfile
.)
After #14.
This would be useful to either document or even integrate into some Rake tasks
https://techoverflow.net/2013/10/22/docker-remove-all-images-and-containers/
https://docs.docker.com/engine/reference/commandline/pause/
This should probably happen automatically after some idle time.
project-manager my-project VAR_A HOST_IP=${hostname -I | awk -F '{ print $1 }'}
Rather than installing .bashrc
with helpers (#5), let's support creating a top-level manager instance that has access to the whole $HOME
.
Since the manager doesn't store any running state, it should always be run as a one-off command with run --rm
.
docker-project-manager run riffr
# docker run -it --rm -v $HOME:/root/host botanicus/dev zsh -c 'tmux ...
docker-project-manager create <my-project> # ...
Bonus: docker-project-manager write-alias
to add alias dpm="docker run -it --rm botanicus/docker-project-manager"
into .bashrc
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.