Trying to deploy web apps via github & docker

Hello!

(TLDR): I have no clue how to setup Github to docker containerization via n8n.
Github > n8n > pull image > build image > push to local docker repo

I really want to start automating my process, I believe that my current setup of pushing to a github repo, building a local copy of my web app, pushing it to my repo and then deploying it is tedious and un-necessarily time consuming.

I have been playing around with n8n and I got a super basic workflow going, where it checks for a git push, so credentials and all are in place, however I am stuck on the actual commands section.
Where it pulls the image from github, builds it, pushes it, etc.

I couldn’t pull the repo using the github blocks, or at least not that I am aware of.
and so my conclusion was to use one of the command execution block things.
However I quickly ran into an issue with them; docker by default uses a gutted /bin/sh which doesn’t even come with a docker-cli, so it was completely useless to me.

I do need some assistance as I have been stuck with no way to move forward.

Hey @ilo32, hope all is well, welcome to the community.

Isn’t it something you would normally do with Github actions?

1 Like

Realistically yes, but i’d like to keep it local.
I do not want to open a direct path to my registry, even if authentication for it is possible.
local is the goto for me.
(plus i’d be interesting to push n8n to it’s limits)

Well if there is a set of commands you’d normally run to perform all the tasks needed, you can use Execute Command node.. If you need commands, which aren’t present in the “getted” container, you can set a docker container alongside your n8n container to do things like building images.

Yeah, I’ve tried that route, although that never worked.
the SH terminal that docker has for n8n is so gutted, it doesn’t even have docker CLI, although I am unsure if this is just docker’s sh or genuinly container based.

in either case, I set n8n’s container to run on the host network.
I am playing around with the idea to create a new folder for n8n commands.
And just use SSH to connect back to my own system and just /bin/bash command.sh.

I’ll see if this works out or not.
the SSH part already is working.

you can always extend the gutted container with your own tools

I heard about it but I never looked into it too carefully, I tried to do something with recreating the image to include some tools, however that didn’t work for me, it kept whining about something.
The SSH route is the only route that seems to work for me right now.

Shouldn’t be all that difficult, here is how to add curl to n8n for instance

Checking it isn’t there:

$ docker exec -it n8n /bin/sh
~ $ curl
/bin/sh: curl: not found

Define a custom image

$ cat Dockerfile
FROM n8nio/n8n

USER root
RUN apk update && apk add --no-cache curl
USER node

Build it

docker build -t n8n-with-curl .

then use it as if it was an original, for example in your docker compose then check again:

$ docker exec -it n8n /bin/sh
~ $ curl --version
curl 8.14.1 (x86_64-alpine-linux-musl)