Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker-less Alpine installation #556

Closed
wants to merge 41 commits into from
Closed

Docker-less Alpine installation #556

wants to merge 41 commits into from

Conversation

Chiogros
Copy link
Contributor

Hi,

The docker-based installation is not convenient for everyone.
For example, a docker-less installation would allow LXC/D containers usage, without using tricky tips for using Docker inside of them.

I already successfully installed a standalone Immich.
This branch would be used for scripting a command-line interactive installation.

Thanks for your feedback!

@Chiogros Chiogros marked this pull request as draft August 31, 2022 12:54
@alextran1502
Copy link
Contributor

FYI, you can run this image to run docker in LXC normally

image

This is how I run Immich on my Promox/LXC setup

@Chiogros
Copy link
Contributor Author

There are some tips to run Docker in LXC containers (playing with nesting option if I remember), although IMO it is not the best way to do.

@alextran1502
Copy link
Contributor

There are some tips to run Docker in LXC containers (playing with nesting option if I remember), although IMO it is not the best way to do.

What are the reasons?

@Chiogros
Copy link
Contributor Author

Chiogros commented Aug 31, 2022

Allowing a container to go out of its initial scope, even if sometimes it can be convenient, is not the good way just for running applications.

In the same way as in Docker you could use --privilegied, running a LXC container with privilegied rights could lead to some security flaws.
(My) PVE is hosting toons of services, I can't imagine a single one being able to disturb the host system.

@alextran1502
Copy link
Contributor

Allowing a container to go out of its initial scope, even if sometimes it can be convenient, is not the good way just for running applications.

In the same way as in Docker you could use --privilegied, running a LXC container with privilegied rights could lead to some security flaws. (My) PVE is hosting toons of services, I can't imagine a single one being able to disturb the host system.

It's my point of view, I though it could interest some people. If not, we can close the PR, no problem.

Fair assessment. I was asking for my knowledge. You are welcome to implement the PR. I bet there are people that don't want to use Docker as a mean of deployment the app

@Chiogros
Copy link
Contributor Author

Great news, thanks!

Alexandre Bouijoux added 12 commits September 3, 2022 18:43
-h shows a help message with arguments accepted by the script
--dev executes script with dev=1, portions of code can change their behavior
while looking at dev's value.
Used for better looking while script is running.
Download immich release and extract it in temp directory.
If in dev mode, the source code must be in the temp directory.
Configure database with a new password and a new database.
The form ask if we want to use an external database, but it is not implemented.
Some extensions are required
Services files for each component allows to start them
on boot.
Service file to start on boot
All existing sites in /etc/nginx/http.d are disabled,
so there are no conflicts for listening on 80 port.
Service file to start ML on boot.
The upload folder is a symlink to the server's upload directory
If not in debug mode, the source code and the archive downloaded
in the temp directory are deleted.
As in debug mode, the source code has been provided, it is not
removed.
@Chiogros
Copy link
Contributor Author

Chiogros commented Sep 4, 2022

There are still a few bugs with Alpine services.
I'm working on.

Alexandre Bouijoux added 5 commits September 4, 2022 19:34
If flags aren't supported, the ML installation in skipped.
Shell scripts run node commands, these one cannot be managed by services.
So when receiving a stop command, child processes are grepped and
-kindly- killed.

Also environment variables are needed for running server components.
@Chiogros
Copy link
Contributor Author

Chiogros commented Sep 4, 2022

Hey @alextran1502,

I solved last bugs, you can try it yourself.
If you encounter anything bad or think things different, please tell me, I'll try to do my best.

I tried to implement machine-learning in Alpine.
I better understand why you have not set up machine-learning in an alpine image...

So for the moment, expected for ML, everything seems to work.
ML installation is skipped.

Thanks for your feedback.

@panoti
Copy link
Contributor

panoti commented Sep 4, 2022

Hi @Chiogros, your contribution is so interesting. Your scripts are quite readable as well. Would you mind if I give you some questions?

  1. Can we put /web/immich-web, /server/immich-server, /server/immich-microservices, /machine-learning/immich-machine-learning in installation directory like alpine.sh? I found that these files may work only with Alpine OS, especially OpenRC.
  2. Can we fetch alpine_ver directly from current user's OS? As you can see if user try to run your script on another alpine version, it can cause error from package updating.

I also have a plan to create standalone docker image by using PM2. I hope I can re-use your script.

@Chiogros
Copy link
Contributor Author

Chiogros commented Sep 4, 2022

Hi @panoti,

Can we put /web/immich-web, /server/immich-server, /server/immich-microservices, /machine-learning/immich-machine-learning in installation directory like alpine.sh? I found that these files may work only with Alpine OS, especially OpenRC.

I first thought about the same architecture as you: ./installation/services/openrc/.
In this way, we could then support systemd-based OS by mkdir-ing ./services/systemd/ and translate openrc services to systemd services.

However, every docker images used are alpine images, excepted for ML. Keeping docker/standalone OS the same would certainly be easier to maintain (same packages name, package manager, shell, ...). But it's a way we could try.

Can we fetch alpine_ver directly from current user's OS? As you can see if user try to run your script on another alpine version, it can cause error from package updating.

Yes, it's on my todo-list :)

Thanks!

@panoti
Copy link
Contributor

panoti commented Sep 5, 2022

I first thought about the same architecture as you: ./installation/services/openrc/. In this way, we could then support systemd-based OS by mkdir-ing ./services/systemd/ and translate openrc services to systemd services.

I really like this organization because it may help us distinguish between service managers.

However, every docker images used are alpine images, excepted for ML. Keeping docker/standalone OS the same would certainly be easier to maintain (same packages name, package manager, shell, ...). But it's a way we could try.

yeah, but I believe that it will make our source code become mess up if we have more kind of service managers like systemd, sysvinit, ....

Yes, it's on my todo-list :)

Sound great, thank you.

installation/alpine.sh Outdated Show resolved Hide resolved

# Build stage
echo "Installing build stage dependencies..."
apk add --no-cache build-base python3 libheif vips-dev ffmpeg nodejs-current npm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is nodejs-current always the lts version of node?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is better to perform node installation with the version specified in the Dockerfile to avoid unexpected behavior of the application

Copy link
Contributor Author

@Chiogros Chiogros Sep 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkgs.org gives packages versions for nodejs on different Alpine versions.
The main nodejs package is running node v14, where nodejs-current is running v16, as in Dockerfiles.
Alpine 3.14 is going EOL in a few months, I don't think they will update nodejs-current over v16.
When Dockerfiles's Alpine version will be updated, we will have to look at the right node package compatible with Immich.

@alextran1502
Copy link
Contributor

Thank you for the detail comments in each file. It helps a lot!

I think we want to include an installation script for Debian/Ubuntu as well. What is your plan on this?

@Chiogros
Copy link
Contributor Author

Chiogros commented Sep 7, 2022

What is your plan on this?

I didn't started anything for Debian/Ubuntu, but I'll start as soon as everything will be okay for Alpine (except ML).

There is one thing and a half to do to support another distro:

  • find the corresponding packages for its package manager + distro + version
  • for systemd family, port OpenRC services files (done once)

The longer will be the first one as you can imagine.

Alexandre Bouijoux added 5 commits September 7, 2022 23:48
web/Dockerfile has been updated, changes have been mirrored in the script.
Partly uninstall and delete immich components,
then compile the updated versions.
node user now executes npm commands to set proper permissions on files
without having to do chowns again and again.
Services files now execute as the node user, a non privilegied user.
@Chiogros Chiogros requested review from panoti and alextran1502 and removed request for panoti and alextran1502 September 8, 2022 21:36
@Chiogros
Copy link
Contributor Author

Chiogros commented Sep 8, 2022

Hi,
I finally managed how to upgrade Immich.
Everything is okay for me, I let you review what have been done since your last feedback.

Alexandre Bouijoux added 6 commits September 10, 2022 12:36
An external nginx server can be used.
The configuration will not be applied locally, but a warning message
will invite to check the repo to see the recommended nginx config.
@alextran1502
Copy link
Contributor

Everything looks good to me. Can you write down some words for the testing procedure and the required environment to test? Thank you for your contribution!

Alexandre Bouijoux added 2 commits September 14, 2022 21:14
Give tips about script options and development procedures for future releases.
A chown on a symlink without trailing / will not apply on target directory.
Also, a note has been added: the storage path should not end with a /.
@Chiogros
Copy link
Contributor Author

Chiogros commented Sep 14, 2022

Everything looks good to me. Can you write down some words for the testing procedure and the required environment to test? Thank you for your contribution!

Hope it is what you were looking for.
If not, please let me know!

@alextran1502
Copy link
Contributor

@Chiogros Thank you, I will spin up an alpine VM and test then let you know the result. We probably need to move all of the instruction to the WIKI to keep things nice and clean in the readme. It is getting long :P

@Chiogros
Copy link
Contributor Author

Hello everybody,
I finally convinced myself to start a Docker VM.
Good luck to everyone who could want to maintain this script.

@Chiogros Chiogros closed this Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants