Docker Perl Sublimetext3 development setup - macos

I am setting up a perl development environment for the first time in a number of years I want to leverage docker and sublime text plus I run on MAC OSX.
I wanted to use Docker to create a dev env that i could share with others on my team.
I like SublimeText and integration with PerlCritic.
I understand about host mounted volumes to allow me to edit locally and save on the docker container.
What I cant work out is how to avoid installing all the perl dependencies on my MAC to enable Sublime to have access to them and allow the sublime perl critic integration to function.
Is it possible to :-
a) Install the complete perl environment in a docker container (this much i know is true)
b) Use SublimeText on my MAC such that all the Sublime Plugins continue to work from the dependencies in the container?
I also understand that Sublime Text has build plugins for perl but from what i understand that occurs at build time not whilst developing - thus still requiring dependencies locally on the MAC.

I would think that you could have your perl install on a mounted docker volume (as you suggested)
Then in the container do
perl -V
which amongst other things will give you
#INC:
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5
.
From your Mac you can then use the PERL5LIB environment to add these to the search path. Ideally these will all be in your mount point. The lib64 sections will not work as these are compiled modules.
export PERL5LIB=/my/docker/mount/perl/lib:/my/docker/mount/lib2
You will probably only need the share sections
I would also match the perl version on the Mac to the docker version by using perlbrew. This is also available in perl -V
Just as a general rule, never mess with the Mac Perl standard install as it causes many problems as the OS uses it for things

Related

What is the easiest way to run bash dependent dockerfiles on windows?

I need to setup docker on my windows 10 OS. I've previously been a linux guy where everything just works so this is a pain for me. It works as expected but within the dockerfile there are calls that uses /bin/bash which makes the build fail.
I've tried to setup a VM with hyper-v but then i stopped because i figured there must be an easier way. I found the bash.exe in windows. i can't run as sudo but i guess that doesn't matter here as long as i run bash as administrator. wget works here but the docker program cant be found when i run docker --version.
Is the easiest way to run bash scripts on win10 with the bash.exe? And why can't docker run in the bash terminal (there is no .bashrc)?
I would use Linux on the Windows box. The two systems can access each other's file systems (\\wsl$, /mnt/c). I use Ubuntu, and it's as if I was using a "normal" Ubuntu box in all aspects, so far. I'd be surprised if your process didn't work here.
Alternatively, there's Cygwin. When running Cygwin, you're kinda in a VM, kinda not. It's a bit blurry. As such, it's not as robust as WSL. But it might do the trick, and it's a lot less "heavy" than installing a full Linux distro.

How to use a docker executable of highest version installed by nix in bash?

Via nix I have a number of docker executables installed on my local machine.
Here is an example:
/nix/store/dbq6mzbsgwv1rnzc52qjbaf33gsfn51z-docker-19.03.4/bin/docker
/nix/store/dbq6mzbsgwv1rnzc52qjbaf33gsfn51z-docker-19.03.4/libexec/docker
/nix/store/dbq6mzbsgwv1rnzc52qjbaf33gsfn51z-docker-19.03.4/libexec/docker/docker
/nix/store/dbq6mzbsgwv1rnzc52qjbaf33gsfn51z-docker-19.03.4/share/bash-completion/completions/docker
/nix/store/fhhly0rgbygghhfmwmdkacrh6cvg6hvg-user-environment/bin/docker
/nix/store/fhhly0rgbygghhfmwmdkacrh6cvg6hvg-user-environment/libexec/docker
/nix/store/fhhly0rgbygghhfmwmdkacrh6cvg6hvg-user-environment/share/bash-completion/completions/docker
I want to able to reuse the docker installed by nix for my dev work. One of the reasons is that the inhouse toolchain relies on a particular version of docker. If I install Docker for Mac I will run into runtime exception.
Is there neat nix command line trick such I can get the path to the highest version of docker? e.g. in the example above I want to use the docker executable under dbq6mzbsgwv1rnzc52qjbaf33gsfn51z-docker-19.03.4. Ideally, I would like to use something like $(nix find-path docker)/bin/docker to invoke the 19.03.04 docker.
I tried nix run docker or nix dump-path docker but of course they are not the right subcommands.
I want to avoid maintaining another BASH variable to hold a hardcoded path to 19.03.04 docker, because my project might upgrade the docker runtimes from time to time.

Optimal way to install ruby on Docker where base-OS access is required?

I'm trying to install Ruby on Docker (no Rails), but I'm having some issues. I initially tried with RVM, but I had issues with it; after I'd installed it in the usual way, commands such as ruby or gem install aren't recognised, and I understand that RVM is not best practice for a docker environment. I tried building from binary, but that seemed to be missing so many essential things, it seemed to be an exercise in futility.
I've now tried using the official docker ruby:2.5.1 image, however when I attach to this, I get an irb prompt, and am unable to use operating system commands, such as apt-get due to this.
It's essential that I have operating system access - this script will be using a browser through headless Watir webdriver, attaching to Geckodriver, so there are a number of dependencies required that won't be included in the base ruby install.
What's the best way to handle this with Docker?
This will get you on the command-line of the Ruby box:
docker run -it ruby:2.5.1 bash
You'll now be able to run ruby tools as normal, e.g. ruby, irb, gem. As well as regular Debian commands including apt-get.
Suggestion:
If you want to roam around inside a separated environment, you should choose something like Vagrant.
If you are intended to use docker, give a try this approach.
You can place any code in your ruby file whichever you would like to.
$ docker run -it -v $(pwd)/:/data ruby:2.5 ruby -- /data/hello.rb
hello world!

Command not found in bas

I'm so sorry because I know this is a dumb question, but I've been trying to figure this out for about 2 hours and I can't figure it out. I've created a bash file that uses some other programs (tcpdump, tshark). The bash runs as it should but on every line that I use tshark, tcpdump, etc. it says "command not found".
I'm using Cygwin on my Windows 7 VM. All of the files are in the same folder and I I've tried adding the locations of the other programs to the PATH variable. I tried commands such as export PATH=$PATH:filelocation but when I do $PATH those results aren't showing. How can I get these commands to be recognized?
Thank you.
current errors
Cygwin is not a Linux distro, therefore, you don't have all the functionality like you would if you had a Linux installation.
You could try one of the following.
1) Use Virtualbox to make a VM of some Linux distro and use bash there. You could use Ubuntu server, which has no GUI.
2) Use this site to find packages that will add functionality to Cygwin.
3)Upgrade to Windows 10 and have a native (sort of) bash to use.

Node.js development, windows or linux?

I'm interested in web development on the Node.js platform. My host OS is Windows 7. What would be the preferd way to set up a development environment. Run it directly on the host or in a linux based virtual machine? What are the pros and cons between these two methods?
If I go with a VM, can I still run the text editor and web browser in Windows (for performance reasons)?
Eh from experience, use Linux Docker.
edit Use Docker. bake in your dependencies, mount your project at run time, pin to a particular version of LTS node only. I'd take a 2gb docker image over un-runnable project leading to days lost being forced to upgrade to new packages. - 2018/04/10
But from someone whose spent the last 8 years developing in a linux based environment, and having spent the last 6 months developing software using nodejs in a windows dot net environment, here are my discoveries, shocking or otherwise...
Problems on windows:
can't effectively utilise docker Latest version of the docker toolkit solves this as far as I'm concerned. ymmv.
most node modules require node_gyp, which on the surface doesn't seem problematic (since gyp is supposed to be cross platform compiler), except when you delve into what it takes to get this working on windows: nothing short of installing visual studio will work. This sucks for me due to several reasons:
I'm normally on linux, so I never want to have to use visual studio.
It's entirely the most ridiculous idea that compiling something on windows requires at minimum a 3GB installation of an IDE... not libs but an entirely monolithic piece of GUI software I'll never ever launch.
the windows equivalent of debians build-essentials is actually a disparate sprawling ill named collection of gui only installers scattered across the internet all requiring a specific installation sequence. This, compared to sudo apt-get install build-essentials is overly time consuming and fraught with hidden gotchas.
developing on windows will allow you the bad habit of mixed case path names, unless your team either has a strict policy that is followed/enforced this will be a slippery slope to problems later on.
while windows supports more than 256 characters in paths, important tooling through out does not. enter stage left: rimraf and robocopy... ugh.
the windows terminal sucks... so does the default shell: cmd.exe...
Powershell is far too verbose in it's syntax and not to my taste... Installing Cmder aleviates this somewhat, however the only way for Cmder to interface with cmd.exe is to basically copy keystrokes to a hidden windows terminal running cmd.exe. (lolwut). Cmder works a lot better with shells that a more modular (zsh, bash, etc).. update: I now use powershell with pshazz and scoop, which is actually pleasant to use.
Having still improved the shell and terminal situation, nodejs for
windows will still assume your environment variables are %OF% %THE%
%WINDOWS% %VARIETY%... not the $UNIX $STYLE. So you'll basically be
using bower and npm mostly from cmd.exe... more ugh. I dont' seem to be having this issue anymore since I've incorporated a mix of cross-env and commander or yargs.
You'll also need to install python for windows, not a problem because choco exists and has you back there. update: have a look at boxstarter, will help automate your new machine setup with recipes (or you could actually graduate to using ansible or salt).
experienced python, ruby developers will tell you that old projects will need the version of their engine silo'd for when you need to revisit them (upgrading to newer versions is mostly not expedient or practical, read: rabbit holes), so you'll want something like rvm and virtualenv...
nvm (which only works on unix systems linux and macosx) because it's
a collection of bash scripts. I recommend using ZSH as your shell along with Zgen and Tarrasch/zsh-autoenv plugin.
nodeenv, which is more likely... a python program that integrates with virtualenv. Some people like this. I have no problem with it, but our team uses nvm.
however, you're better off with nvm-windows because "reasons". scratch that, use nodist on windows... bar far the better choice, you won't need to worry about some kind of autoenv since nodist by design handles this.
Installing on Windows:
install chocolatey
choco install cmder nodejs python2 choco install python2
install http://scoop.sh, then use it to install pshazz.
remove any versions of node manually installed globally.
install nvm-windows install nodist.
install visual-studio 2012 express, then never launch it if you treasure your cpu cycles. this may be overkill as microsoft have released an equivalent to build-essentials.
install windows 7/10 64bit sdk
Problems on Linux:
tldr; use nvm. for more reasons other than the below.
you'll have to set the global npm node_modules path to a user owned directory (I've started using ~/.local/share/npm). Pleasantly, this is something I found the windows installation of nodejs got right (probably not intentionally). A non issue when using nvm.
Ubuntu already has a binary called node, so #!/usr/bin/env node will by default not run nodejs. luckily debian systems have a neat management tool for controlling what the env binary emits: update-alternatives. ignore suggestions to use symlinks here, which will only cause problems later on in subtle ways. also a non issue when using nvm.
Installing on Linux :
$ sudo apt-get install git-core git-flow build-essentials python-dev python- pip
$ curl https://raw.githubusercontent.com/creationix/nvm/v0.20.0/install.sh | bash
$ npm config set prefix ~/.local/share/npm
$ nvm install stable
$ nvm alias default stable
references:
https://groups.google.com/forum/?fromgroups#!msg/msysgit/9YIR6jlNB0Q/zHhPN3tejFkJ
https://github.com/creationix/nvm
http://bliker.github.io/cmder/
https://github.com/coreybutler/nvm-windows
https://github.com/Tarrasch/zsh-autoenv
https://github.com/lukesampson/pshazz
http://scoop.sh
https://github.com/marcelklehr/nodist
We have a system via which we just use a config file, which handles all our problems like path differences ("c:\blarg" vs "~user/blarg") and, as a bonus, lets us control differences between debug and production environments.
Node.js is cross platform, so we totally have developers working on all sorts of computers, and it's no problem at all.
This is an example config file I use on a file storage project:
/**
* All of these are mandatory except for log_level (which defaults to "info", 1)
* and log_echo_to_console (which defaults to false)
*/
exports.config = {
log_level: 0,
log_file: "/path/to/send.log",
request_log_file: "/path/to/send_requests.log",
log_echo_to_console: true,
port_number: 8088,
no_notification_emails: true,
image_url_base: "http://s3.amazonaws.com/", // MAKE SURE THIS ENDS IN "/"
tmp_file_folder:"/tmp/",
s3_info: {
key: 'xxxxxx',
secret: 'yyyyy',
file_bucket: 'sendtransfer/',
},
backend_info: {
db_info: {
server: "localhost",
user: "db_user",
password: "secret",
database: "SendRemote",
pooled_connections: 125,
idle_timeout_millis: 30000
},
memcache_info: {
host: "127.0.0.1",
port: "31111",
pooled_connections: 200,
timeout: 20000
}
},
debug_server: true
};
For Windows machines, just change the paths. It's all good!
Then in code, you can just type:
var local = require('local.config.js');
fs.writeFile(local.config.log_file);
// etc
Embrace multiculturalism!!!
I am also on Windows 7 and use Virtualbox with a Linux ( debian ) guest, i would recommand it because I for myself am faster doing some stuff in the commandline then clicking arround in Windows.
Another nice feature is that if you put your VM on an USB stick you can take it with you and use it everywhere where a Virtualbox Host is installed, so you can take your whole development environment with you.
It's no problem at all to use your favourite text editor or browser in Windows, just install samba and mount your home directory into Windows.
Same goes for your browser since the VM is just another machine in your LAN, instead of pointing your browser to localhost point it to the VMs Ip and you are fine.
Obvious con here is if you don't have any experience with Linux yet you should probably stick to windows because it will take you some time to get into it.
just my two cents maybe even less:
I'll suggest you a third option: to double install windows/ubuntu setup (preferably ubuntu dist which is most gui friendly) and research this option as well this way you would be more familiar with the linux/unix and even iOS which will even make you understand windows better and a better programmer. Sometimes the virtual box is too slow, while linux is very efficient with resources.
If you have the ability to install a virtual machine,you can also give a go to installing a linux distribution and get yourself familiar with this language/system of OS which a lot of the web is structured upon
I really enjoy coding node.js on windows using git bash:
http://blog.nodester.com/post/19902515151/tips-for-windows-users
It's seems faster then and easier then running VirtualBox. Given that I still use Virtual Box for testing before going to production.

Resources