Lately I've been messing about with my new CTC 3D printer, but soon figured out that the whole 3D printing set up could do with some upgrades.
Before moving on to what is currently running in the office, I thought I'd break the subjects down a bit:
- Setting up LEDs and case fans on the printer chassis
- Figuring out a way to control them remotely
Since I'm already using a Cubietruck, I thought about using the GPIOs to control these external components. Still, that solution wouldn't be that different from what you can do with a Cubieboard, Cubietruck, Raspberry Pi and similar embedded boards, ranging from 40USD upwards.
So then I found out about the ESP8266-01 wifi module:
This tiny wifi module costs about 2USD (!!!) and while a lot of people consider it mainly as a cheap wifi upgrade for their arduino boards, it can do quite a bit on its own...!
I bought a few of these on Ebay recently, just curious about what I could actually do with them, so in the end, this little guy alone ended up controlling the LEDs and case fans on my 3D printer chassis.
But first off, an important disclaimer:
The electronics on this project was mostly picked up from tips and teachings from a couple of friends, more knowledgeable on the subject.
I'll be posting the several steps in this project on the blog, as soon as I'm able to clean up all the mess around the office...!
Coding Chase - Projects
Sunday, 12 July 2015
Sunday, 21 June 2015
Cubietruck and a CTC Dual Extruder Printer - Part II
From the previous post, the CTC Dual Extruder is now connected to a Cubietruck running Octoprint, together with the GPX plugin.
At thingiverse you get all sorts of models, or things. Downloading the STL file and passing it on to the printer didn't work, so here's how I did it:
On my client PC I have ReplicatorG installed - I'm running Linux Mint and it installed properly on my laptop.
Loading the STL on ReplicatorG, you get to set up some basic variables such as extruder temperature and so on - and then you get the chance to generate a gcode file.
This is ideal, because Mark Walker's GPX plugin for Octoprint understands gcode and converts it to x3g for the printer!
So now I'm on my PC, there's a generated gcode file - all I have to do is upload it to Octoprint on Cubietruck using the WebUI and initiate the print job!
Print estimates, statistics and more are all visible on Octoprint - and going a step further, why not plug a USB Webcam to Cubietruck as well and stream all the action...? :)
I'll keep at this, hopefully with both extruders, different materials... let's see!
At thingiverse you get all sorts of models, or things. Downloading the STL file and passing it on to the printer didn't work, so here's how I did it:
On my client PC I have ReplicatorG installed - I'm running Linux Mint and it installed properly on my laptop.
Loading the STL on ReplicatorG, you get to set up some basic variables such as extruder temperature and so on - and then you get the chance to generate a gcode file.
This is ideal, because Mark Walker's GPX plugin for Octoprint understands gcode and converts it to x3g for the printer!
So now I'm on my PC, there's a generated gcode file - all I have to do is upload it to Octoprint on Cubietruck using the WebUI and initiate the print job!
Print estimates, statistics and more are all visible on Octoprint - and going a step further, why not plug a USB Webcam to Cubietruck as well and stream all the action...? :)
I'll keep at this, hopefully with both extruders, different materials... let's see!
Cubietruck and a CTC Dual Extruder Printer - Part I
So, recently I bought a 3D printer - the CTC Dual Extruder. This device is actually a Makerbot Replicator 2 clone.
I've only had it for about 2 days, haven't changed firmwares or anything (it seems most experienced users recommend the Sailfish firmware) and for the time being, don't plan on messing with that.
And to be fair, the pre-installed firmware seems to be quite complete, so I'll keep it for as long as it suits my needs.
The printer has an SD card slot and a USB port. I started by using the SD card, but soon decided it would be preferable to move on to USB.
And what if you could WiFi it...?
Turns out, you can!
The CTC printer is USB connected to my Cubietruck and accessible over WiFi - or even from the internet, given the proper network configuration...!
To achieve this, I needed to set up octoprint on Cubietruck.
1) connecting the CTC dual extruder 3d printer to Cubietruck (Cubian)
cubie@Cubian:~$ sudo dmesg -c
connect the printer to cubietruck, on USB
cubie@Cubian:~$ dmesg
[ 255.900873] ehci_irq: port change detect
[ 255.905231] ehci_irq: port change detect
[ 255.969149] ehci_irq: port change detect
[ 256.206068] ehci_irq: port change detect
[ 256.261515] The port change to OHCI now!
[ 256.564307] usb 2-1: new full-speed USB device number 2 using sw-ohci
[ 257.278351] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.294415] cma: dma_alloc_from_contiguous(): returned d1078c80
[ 257.300276] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.314439] cma: dma_alloc_from_contiguous(): returned d1078ca0
[ 257.320294] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.334443] cma: dma_alloc_from_contiguous(): returned d1078cc0
[ 257.340297] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.364339] cma: dma_alloc_from_contiguous(): returned d1078ce0
[ 257.370194] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.384427] cma: dma_alloc_from_contiguous(): returned d1078e00
[ 257.390279] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.408925] cma: dma_alloc_from_contiguous(): returned d1078e20
[ 257.424778] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.430357] cma: dma_alloc_from_contiguous(): returned d1078e40
[ 257.444711] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.454701] cma: dma_alloc_from_contiguous(): returned d1078e60
[ 257.460552] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.484272] cma: dma_alloc_from_contiguous(): returned d1078e80
[ 257.490176] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.504485] cma: dma_alloc_from_contiguous(): returned d1078ea0
[ 257.510341] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.524444] cma: dma_alloc_from_contiguous(): returned d1078ec0
[ 257.530302] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.554409] cma: dma_alloc_from_contiguous(): returned d1078ee0
[ 257.560397] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.574399] cma: dma_alloc_from_contiguous(): returned d1078f00
[ 257.580256] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.604411] cma: dma_alloc_from_contiguous(): returned d1078f20
[ 257.610266] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.624412] cma: dma_alloc_from_contiguous(): returned d1078f40
[ 257.630265] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.654296] cma: dma_alloc_from_contiguous(): returned d1078f60
[ 257.660154] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.674425] cma: dma_alloc_from_contiguous(): returned d1078f80
[ 257.680281] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.708866] cma: dma_alloc_from_contiguous(): returned d1078fa0
[ 257.713053] cdc_acm 2-1:1.0: ttyACM0: USB ACM device
[ 257.721023] usbcore: registered new interface driver cdc_acm
[ 257.728303] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
2) cubietruck - install octoprint with GPX plugin
sudo usermod -a -G tty cubie
sudo usermod -a -G dialout cubie
log out / log in
cubie@Cubian:~$ groups
cubie tty dialout sudo audio video gpio
sudo apt-get install python-pip python-dev python-setuptools python-virtualenv git libyaml-dev
sudo apt-get clean
cd
mkdir ~/.octoprint
git clone -b devel https://github.com/markwal/OctoPrint
cd OctoPrint
git rev-parse HEAD (mine is at commit 3857e7e0b04d7c72ab5d11df952fc21d61aa78ca)
virtualenv --system-site-packages venv
./venv/bin/python setup.py install
git clone https://github.com/markwal/OctoPrint-GPX
cd OctoPrint-GPX
git rev-parse HEAD (mine was at 64586f1e18188acbea0e22828a479c216cff287d)
git submodule update --init
../venv/bin/python setup.py install
cd
~/OctoPrint/venv/bin/octoprint
the output should show something like this:
(...)
2015-06-21 10:40:55,832 - octoprint.plugin.core - INFO - Found 6 plugin(s) providing 6 mixin implementations, 3 hook handlers
2015-06-21 10:40:55,852 - octoprint.plugin.core - INFO - Initialized 6 plugin(s)
2015-06-21 10:40:55,855 - octoprint.plugin.core - INFO - 6 plugin(s) registered with the system:
| CuraEngine (bundled) = /home/cubie/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.0_dev_973_g3857e7e-py2.7.egg/octoprint/plugins/cura
| Discovery (bundled) = /home/cubie/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.0_dev_973_g3857e7e-py2.7.egg/octoprint/plugins/discovery
| GPX (0.3.1-9.g64586f1) = /home/cubie/OctoPrint/venv/local/lib/python2.7/site-packages/OctoPrint_GPX-0.3.1_9.g64586f1-py2.7-linux-armv7l.egg/octoprint_GPX
| Plugin Manager (bundled) = /home/cubie/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.0_dev_973_g3857e7e-py2.7.egg/octoprint/plugins/pluginmanager
| Software Update (bundled) = /home/cubie/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.0_dev_973_g3857e7e-py2.7.egg/octoprint/plugins/softwareupdate
| Virtual Printer (bundled) = /home/cubie/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.0_dev_973_g3857e7e-py2.7.egg/octoprint/plugins/virtual_printer
(...)
In the web browser, at http://<cubian_ip>:5000, login in and add a new device on the left panel:
select Serial Port /dev/ttyACM0 > Baudrate 115200 > everything else auto > Connect
... and you should get a Machine State: Operational :)
Now from here, you can create startup scripts - in my case, I just use screen and run the octoprint command on a detached terminal.
The base for this set up is this guide from Octprint, for the Raspberry Pi
https://github.com/foosel/OctoPrint/wiki/Setup-on-a-Raspberry-Pi-running-Raspbian
...and Mark Walker's work on the GPX Plugin, essential for connecting this printer with Octoprint
https://github.com/markwal/OctoPrint-GPX
As for doing some 3D printing with this set up: check out the next post!
I've only had it for about 2 days, haven't changed firmwares or anything (it seems most experienced users recommend the Sailfish firmware) and for the time being, don't plan on messing with that.
And to be fair, the pre-installed firmware seems to be quite complete, so I'll keep it for as long as it suits my needs.
The printer has an SD card slot and a USB port. I started by using the SD card, but soon decided it would be preferable to move on to USB.
And what if you could WiFi it...?
Turns out, you can!
The CTC printer is USB connected to my Cubietruck and accessible over WiFi - or even from the internet, given the proper network configuration...!
To achieve this, I needed to set up octoprint on Cubietruck.
1) connecting the CTC dual extruder 3d printer to Cubietruck (Cubian)
cubie@Cubian:~$ sudo dmesg -c
connect the printer to cubietruck, on USB
cubie@Cubian:~$ dmesg
[ 255.900873] ehci_irq: port change detect
[ 255.905231] ehci_irq: port change detect
[ 255.969149] ehci_irq: port change detect
[ 256.206068] ehci_irq: port change detect
[ 256.261515] The port change to OHCI now!
[ 256.564307] usb 2-1: new full-speed USB device number 2 using sw-ohci
[ 257.278351] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.294415] cma: dma_alloc_from_contiguous(): returned d1078c80
[ 257.300276] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.314439] cma: dma_alloc_from_contiguous(): returned d1078ca0
[ 257.320294] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.334443] cma: dma_alloc_from_contiguous(): returned d1078cc0
[ 257.340297] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.364339] cma: dma_alloc_from_contiguous(): returned d1078ce0
[ 257.370194] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.384427] cma: dma_alloc_from_contiguous(): returned d1078e00
[ 257.390279] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.408925] cma: dma_alloc_from_contiguous(): returned d1078e20
[ 257.424778] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.430357] cma: dma_alloc_from_contiguous(): returned d1078e40
[ 257.444711] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.454701] cma: dma_alloc_from_contiguous(): returned d1078e60
[ 257.460552] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.484272] cma: dma_alloc_from_contiguous(): returned d1078e80
[ 257.490176] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.504485] cma: dma_alloc_from_contiguous(): returned d1078ea0
[ 257.510341] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.524444] cma: dma_alloc_from_contiguous(): returned d1078ec0
[ 257.530302] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.554409] cma: dma_alloc_from_contiguous(): returned d1078ee0
[ 257.560397] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.574399] cma: dma_alloc_from_contiguous(): returned d1078f00
[ 257.580256] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.604411] cma: dma_alloc_from_contiguous(): returned d1078f20
[ 257.610266] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.624412] cma: dma_alloc_from_contiguous(): returned d1078f40
[ 257.630265] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.654296] cma: dma_alloc_from_contiguous(): returned d1078f60
[ 257.660154] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.674425] cma: dma_alloc_from_contiguous(): returned d1078f80
[ 257.680281] cma: dma_alloc_from_contiguous(cma ef0ab1c0, count 1, align 0)
[ 257.708866] cma: dma_alloc_from_contiguous(): returned d1078fa0
[ 257.713053] cdc_acm 2-1:1.0: ttyACM0: USB ACM device
[ 257.721023] usbcore: registered new interface driver cdc_acm
[ 257.728303] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
2) cubietruck - install octoprint with GPX plugin
sudo usermod -a -G tty cubie
sudo usermod -a -G dialout cubie
log out / log in
cubie@Cubian:~$ groups
cubie tty dialout sudo audio video gpio
sudo apt-get install python-pip python-dev python-setuptools python-virtualenv git libyaml-dev
sudo apt-get clean
cd
mkdir ~/.octoprint
git clone -b devel https://github.com/markwal/OctoPrint
cd OctoPrint
git rev-parse HEAD (mine is at commit 3857e7e0b04d7c72ab5d11df952fc21d61aa78ca)
virtualenv --system-site-packages venv
./venv/bin/python setup.py install
git clone https://github.com/markwal/OctoPrint-GPX
cd OctoPrint-GPX
git rev-parse HEAD (mine was at 64586f1e18188acbea0e22828a479c216cff287d)
git submodule update --init
../venv/bin/python setup.py install
cd
~/OctoPrint/venv/bin/octoprint
the output should show something like this:
(...)
2015-06-21 10:40:55,832 - octoprint.plugin.core - INFO - Found 6 plugin(s) providing 6 mixin implementations, 3 hook handlers
2015-06-21 10:40:55,852 - octoprint.plugin.core - INFO - Initialized 6 plugin(s)
2015-06-21 10:40:55,855 - octoprint.plugin.core - INFO - 6 plugin(s) registered with the system:
| CuraEngine (bundled) = /home/cubie/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.0_dev_973_g3857e7e-py2.7.egg/octoprint/plugins/cura
| Discovery (bundled) = /home/cubie/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.0_dev_973_g3857e7e-py2.7.egg/octoprint/plugins/discovery
| GPX (0.3.1-9.g64586f1) = /home/cubie/OctoPrint/venv/local/lib/python2.7/site-packages/OctoPrint_GPX-0.3.1_9.g64586f1-py2.7-linux-armv7l.egg/octoprint_GPX
| Plugin Manager (bundled) = /home/cubie/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.0_dev_973_g3857e7e-py2.7.egg/octoprint/plugins/pluginmanager
| Software Update (bundled) = /home/cubie/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.0_dev_973_g3857e7e-py2.7.egg/octoprint/plugins/softwareupdate
| Virtual Printer (bundled) = /home/cubie/OctoPrint/venv/lib/python2.7/site-packages/OctoPrint-1.2.0_dev_973_g3857e7e-py2.7.egg/octoprint/plugins/virtual_printer
(...)
In the web browser, at http://<cubian_ip>:5000, login in and add a new device on the left panel:
select Serial Port /dev/ttyACM0 > Baudrate 115200 > everything else auto > Connect
... and you should get a Machine State: Operational :)
Now from here, you can create startup scripts - in my case, I just use screen and run the octoprint command on a detached terminal.
The base for this set up is this guide from Octprint, for the Raspberry Pi
https://github.com/foosel/OctoPrint/wiki/Setup-on-a-Raspberry-Pi-running-Raspbian
...and Mark Walker's work on the GPX Plugin, essential for connecting this printer with Octoprint
https://github.com/markwal/OctoPrint-GPX
As for doing some 3D printing with this set up: check out the next post!
3D Printing
Recently I've decided to buy a 3D printer. Completely unaware of all the complexities behind 3D printing, I set out to choose one.
Although 3D printers have been around for a while now, buying one can be a challenging task, from price tag to print area size, print detail, print speed... etc etc etc etc.
First of all, there are a couple of websites which help a lot:
So, since my budget wasn't that high, I eventually decided to buy a CTC Dual Extruder Printer.
https://www.3dhubs.com/3d-printers/ctc-3d
The reviews are mixed everywhere, there's people complaining about reliability, customer service and then the success cases... oh well, I decided to take a gamble.
I got it from ebay, shipped from Hamburg, and about a week later, I had it in my study!
I still have pretty much everything to learn from 3D printing, but after printing a couple of models, I'm actually pretty pleased with the quality, functionality and practicality of it...! :)
There are quite a few youtube videos out there about this printer, basically it's already pre-assembled, all you have to do is screw in the extruders head and set up the filament spool.
A couple of advices with this: take your time. Read and watch as much as you need to feel comfortable with the device.
If you feel the need to peel stuff off - don't! Make sure you're supposed to.
I'm still to try out the second extruder, different materials, etc. etc. etc. - but so far, one weekend in and I've been having quite a lot of fun with this printer!
Although 3D printers have been around for a while now, buying one can be a challenging task, from price tag to print area size, print detail, print speed... etc etc etc etc.
First of all, there are a couple of websites which help a lot:
- https://www.3dhubs.com/
- http://www.thingiverse.com/
So, since my budget wasn't that high, I eventually decided to buy a CTC Dual Extruder Printer.
https://www.3dhubs.com/3d-printers/ctc-3d
The reviews are mixed everywhere, there's people complaining about reliability, customer service and then the success cases... oh well, I decided to take a gamble.
I got it from ebay, shipped from Hamburg, and about a week later, I had it in my study!
I still have pretty much everything to learn from 3D printing, but after printing a couple of models, I'm actually pretty pleased with the quality, functionality and practicality of it...! :)
There are quite a few youtube videos out there about this printer, basically it's already pre-assembled, all you have to do is screw in the extruders head and set up the filament spool.
A couple of advices with this: take your time. Read and watch as much as you need to feel comfortable with the device.
If you feel the need to peel stuff off - don't! Make sure you're supposed to.
I'm still to try out the second extruder, different materials, etc. etc. etc. - but so far, one weekend in and I've been having quite a lot of fun with this printer!
Saturday, 14 February 2015
QtQuick3D and SailfishOS (Jolla)
Recently I've been doing some work with Blender and since I have a soft spot for Qt and there was a Jolla phone laying around, I decided to do some research into how to get already made 3D models to work within a SailfishOS App.
And the result was impressive - not just visually, but also code-wise:
This example is from QtStudios and the source code I got was QtQuick1 - so I decided to try and integrate it in a normal SailfishOS App. The original QtQuick3D tutorial is available here:
What I found best about all this was that the pre-made 3D model could be imported and handled in QML, rather than C++ only - although not sure if Jolla would allow for this particular Qt Module to be used in a Jolla Store published app.
Regardless, it does make way for some interesting developments especially by combining it with Blender, the open source project!
In the meantime, if you own a Jolla phone and wish to try this out, go grab my version using either of the links below:
Jolla SailfishOS variant:
git@bitbucket.org:wickwire/sailfishos-qtquick3d-example.git git@gitlab.com:wickwire/SailfishOS-QtQuick3D-Example.git
And the result was impressive - not just visually, but also code-wise:
This example is from QtStudios and the source code I got was QtQuick1 - so I decided to try and integrate it in a normal SailfishOS App. The original QtQuick3D tutorial is available here:
What I found best about all this was that the pre-made 3D model could be imported and handled in QML, rather than C++ only - although not sure if Jolla would allow for this particular Qt Module to be used in a Jolla Store published app.
Regardless, it does make way for some interesting developments especially by combining it with Blender, the open source project!
In the meantime, if you own a Jolla phone and wish to try this out, go grab my version using either of the links below:
Jolla SailfishOS variant:
git@bitbucket.org:wickwire/sailfishos-qtquick3d-example.git git@gitlab.com:wickwire/SailfishOS-QtQuick3D-Example.git
Monday, 9 February 2015
Cubieboard + Gitlab Update
... And my Cubieboard A20 has been running Gitlab and managing code for 19 days and 15min, without a hitch! ;)
Tuesday, 20 January 2015
Cubieboard + Gitlab
I like hosting my pet projects on bitbucket.org. The free account includes both private and public projects, there's a wiki section, so far I've had zero issues with their services...
But recently I considered mirroring the projects there to other similar git cloud solutions, for backup.
After some google searching, I could just configure my local git repositories (on my PC) to "multipush" to bitbucket.org and gitlab.com (the other similar git cloud solution I ended up going for).
However, I had to replicate my "multipush" configuration accross any machine I would work at, as well as be prompted for my ssh passphrase about 4 times on each push action - and on top of that, if anyone else were to work with me collaboratively, we would all have to be extra careful in updating the cloud instances and make sure that one cloud service wouldn't get a different history than the other.
So, I decided to invest some more time with the issue and came up with what I consider to be, the ideal approach, in my case anyways:
So basically, I'm using a Cubieboard to run a Gitlab installation (as Gitlab exists both as a cloud service and as open source software that you can install and run privately), everyone pushes to that instance, and that instance alone communicates with the cloud services.
This clears any potential cloud service history mismatches as there is only one git server frontend to the developers, and ensures code replication/backup to multiple services on the cloud as well.
Note that while this setup is working, it might be worth it to consider the total volume of code generation, developers involved, etc. and replace the Cubieboard with something more robust if needed, in the long run, if that's you.
But anyways, this post is mainly about code versioning, with cloud replication, using free services and relatively cheap and low power consuming infrastructure - and Cubieboard is handling itself after 3 days non-stop usage, with a total 490MB RAM being used by the system.
That said, I'll be including my notes throughout the whole process, it took a while to get everything working, there are hacks along the way and first and foremost, the online resources I based my guide on:
- http://ruiabreu.org/2011-10-27-git-workflow-pushing-to-multiple-repos.html
- http://krisko210.blogspot.pt/2014/07/installing-gitlab-on-odroid-archlinuxarm.html
- http://elijahpaul.co.uk/using-an-smtp-server-with-gitlab/
- https://mcwhirter.com.au/craige/blog/2014/Post_Receive_Git_Hook_to_Push_to_Github/
- http://doc.gitlab.com/ce/hooks/custom_hooks.html
(my) Cubieboard + Gitlab Tutorial
(Using Cubieboard A20 with Cubian X1 nano headless)
Table of Contents
sudo apt-get install git ruby patch ruby1.9.1-dev libmysqlclient-dev libmysqld-dev libicu-dev build-essential mysql-server redis-server libpq-dev
wget http://nodejs.org/dist/v0.10.35/node-v0.10.35.tar.gz
tar xvzpf node-v0.10.35.tar.gz
cd node-v0.10.35
./configure --without-snapshot
make -j3
sudo make install
mysql -u root -p
CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab';
SET storage_engine=INNODB;
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost' IDENTIFIED BY 'gitlab';
quit
cd ~
sudo gem install bundler --no-ri --no-rdoc
git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-1-stable gitlab
cd gitlab
cp config/gitlab.yml.example config/gitlab.yml
nano config/gitlab.yml
host: localhost #or 192.168.1.10, using static dhcp with the LAN router
port: 4343
# If you use non-standard ssh port you need to specify it << cubian sets sshd port to 36000, keeping it
ssh_port: 36000
chown -R git log/ tmp/
chmod -R u+rwX log/ tmp/
mkdir ~/gitlab-satellites
chmod u+rwx,g=rx,o-rwx ~/gitlab-satellites
chmod -R u+rwX tmp/pids/ tmp/sockets/ public/uploads
cp config/unicorn.rb.example config/unicorn.rb
nano config/unicorn.rb
listen "/home/git/gitlab/tmp/sockets/gitlab.socket", :backlog => 64
listen "localhost:4343", :tcp_nopush => true #or 192.168.1.10, using static dhcp with the LAN router
cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
git config --global user.name "GitLab"
git config --global user.email "mymail@gmail.com"
git config --global core.autocrlf input
cp config/database.yml.mysql config/database.yml
nano config/database.yml
...set DB preferences here...
nano Gemfile
#gem "therubyracer"
nano Gemfile.lock
therubyracer (0.12.0) << delete
libv8 (~> 3.16.14.0) << delete
bundle install --no-deployment --path vendor/bundle
bundle install --deployment --without development test postgres aws
confirm that the redis daemon is running (should be, at this point) > netstat -an | grep 6379
bundle exec rake gitlab:shell:install[v1.9.6] REDIS_URL=redis://localhost:6379 RAILS_ENV=production
bundle exec rake gitlab:setup RAILS_ENV=production
login.........admin@local.host
password......5iveL!fe
cp lib/support/init.d/gitlab ~/gitlab-start-stop (start as user git)
cd ~
./gitlab-start-stop start (wait for a few minutes for it to start and release the cli)
cd gitlab
bundle exec rake gitlab:env:info RAILS_ENV=production
bundle exec rake assets:precompile RAILS_ENV=production
as root: cp /home/git/gitlab/lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
nano gitlab/config/gitlab.yml
-> email_from: <valid_email_address>
nano gitlab/config/environments/production.rb
-> change sendmail to smtp
config.action_mailer.delivery_method = :smtp
cp gitlab/config/initializers/smtp_settings.rb.sample gitlab/config/initializers/smtp_settings.rb
configure an email account (gmail example)
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail.com',
:user_name => 'account@gmail.com',
:password => 'password',
:authentication => :plain,
:enable_starttls_auto => true
}
restart gitlab
http://192.168.1.10:4343
username: root << in my case, admin@local.host didn't work, root did
password: 5iveL!fe
The user should now receive the password at his valid email address (and possibly in Junk/Spam)
On Cubian, as git user:
cd ~
nano gitlab-shell/config.yml
gitlab_url: http://192.168.1.10:4343/
restart gitlab server
Cubian sshd runs on port 36000, so on the client, edit ~/.ssh/config if you wish to facilitate things:
Host 192.168.1.10
Hostname 192.168.1.10
Port 36000
cd ~
sudo cp gitlab-start-stop /etc/init.d/
sudo -s
update-rc.d gitlab-start-stop defaults
Cubian:
git user, generate ssh keypair without passphrase
gitlab.com/bitbucket.org, add id_rsa.pub from the git user
from Cubian, test ssh access:
ssh git@gitlab.com >> Welcome to GitLab, Wickwire!
ssh git@bitbucket.org >> logged in as wickwire.
on Cubian, configure remotes for the gitlab server
for each repository, done once:
cd ~/repositories/wickwire/raspberry-pi-qrdecoder.git
cat config
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "gitlab"]
url = git@gitlab.com:wickwire/raspberry-pi-qrdecoder.git
fetch = +refs/heads/*:refs/remotes/gitlab/*
fetch = +refs/tags/*:refs/tags/*
autopush = true
[remote "bitbucket"]
url = git@bitbucket.org:wickwire/raspberry-pi-qrdecoder.git
fetch = +refs/heads/*:refs/remotes/bitbucket/*
fetch = +refs/tags/*:refs/tags/*
autopush = true
cat hooks/post-receive
#!/bin/bash
for remote in $(git remote); do
if [ "$(git config "remote.${remote}.autopush")" = "true" ]; then
git push "$remote" --all -u
git push "$remote" --tags
fi
done
chmod a+x hooks/post-receive
gitlab reload
On client, first time synching local Gitlab and remotes:
git remote -v
git remote rm origin
git remote add origin <remote repo git url>
git push -u origin --all # pushes up the repo and its refs for the first time
(repeat for all the cloud git services)
git remote rm origin
git add origin <local gitlab server repo>
from here, add content -> git add -A -> git commit -m "msg" -> git push - and it should all work, your code should be safely pushed to all instances: the Cubian GitLab and the cloud services.
This was a little trickier as editing wiki pages using the web browser didn't seem to trigger any Cubian GitLab repository hooks, and the web hook setup for GitLab didn't seem to help either - so I ended up using a "quick and dirty hack" to make it work:
Cron job running every 5min on user git, just to push any new changes at the Cubian GitLab Wiki repo
clone the bitbucket wiki first and manually push it to gitlab Cubian and gitlab.com
git clone git@bitbucket.org:wickwire/raspberry-pi-qrdecoder.git/wiki
cd wiki
#replace the bitbucket origin with the gitlab.com origin
git remote rm origin
git remote add origin git@gitlab.com:wickwire/raspberry-pi-qrdecoder.wiki.git
#force initial push to gitlab.com
git push --force origin --all
#replace the gitlab.com origin with the gitlab cubian origin
git remote rm origin
git remote add origin ssh://git@192.168.1.10:36000/wickwire/raspberry-pi-qrdecoder.wiki.git
git push --force origin --all
On Cubian Gitlab, as git user:
~/repositories/wickwire/raspberry-pi-qrdecoder.wiki.git
cat config
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "gitlab"]
url = git@gitlab.com:wickwire/raspberry-pi-qrdecoder.wiki.git
fetch = +refs/heads/*:refs/remotes/gitlab/*
autopush = true
[remote "bitbucket"]
url = git@bitbucket.org:wickwire/raspberry-pi-qrdecoder.git/wiki
fetch = +refs/heads/*:refs/remotes/bitbucket/*
autopush = true
cat hooks/post-receive-crontab
#!/bin/bash
WORKDIR=`dirname $0`
cd $WORKDIR
for remote in $(git remote); do
if [ "$(git config "remote.${remote}.autopush")" = "true" ]; then
git push "$remote"
fi
done
git user cron:
*/5 * * * * /home/git/repositories/wickwire/raspberry-pi-qrdecoder.wiki.git/hooks/post-receive-crontab >/dev/null 2>&1
All new entries on the wiki for this repo, using the traditional GitLab WebUI will be pushed to the cloud git repositories, every 5 minutes.
And that's it!
If you've survived this long, then you should have a working GitLab server running on your Cubieboard and while pushing code or adding/updating wiki content to it, all changes should be pushed to the cloud as well! :)
Subscribe to:
Posts
(
Atom
)


