Easy Self Host Icon

Immich: Self-Hosted Photo Backup and Google Photos Alternative

Video

Transcript

In this video we are going to run immich.

Which is a photo and video management solution,

that offers features like auto-backup, nice-looking mobile app, smart search, face detection and many more.

Itā€™s just like a self-hosted version of google photo.

Iā€™m going to show you how to set up the immich server and back up photos using its mobile app.

Letā€™s get started with setting up the server.

Immich recommends using Docker Compose and offers a Docker Compose template for setup.

We'll take this template as our foundation and tweak it to integrate with our proxy server.

You can find their docker compose file on their website under the docker compose section.

Here is the docker compose file after some changes

The differences are highlighted by the editor

We start by adding the proxy docker network

We are going to use this network to connect our proxy server and the immich server

For the service section, there are 5 services defined by the original docker compose file.

Iā€™ll go over them and explain their functionalities and where I made changes

The first service is the immich-server, it handles user-facing requests from mobile and web apps, and it also serves the web content.

Itā€™s using the official immich-server image with a command to start the core immich server.

Here I add the network config for the immich server with both the default and the proxy network.

The default network connects the server with the rest of the services in this docker compose.

The proxy network connects the server with the proxy server defined in another docker-compose file.

For the volume section, we first define the location to store the uploaded photos.

The actual location is defined by this environment variable UPLOAD_LOCATION.

This variable is configured in the .env file.

Here I set it to a docker volume named upload.

And the volume is defined in the docker compose file at the end.

You can also configure it to a path on the server host filesystem.

It can be easier to access the actual files this way.

Here we also specify the env file to the .env we just saw.

This is for setting the environments of the server for configs like database credentials.

We are going to talk about it in a moment.

Next I changed the ports config to expose since we donā€™t need to publish any ports to the server.

The proxy server can access this service with the docker network.

Actually the expose config is just for documentation purposes since the original image already exposes this port.

This service depends on the redis and the database service so it will start after them.

I also change all the restart policies in the original docker compose from always to unless-stopped.

It gives us some flexibility to disable individual service but it wonā€™t make any difference in most cases.

The next service is the immich microservices.

Despite its naming, it actually does not handle any web request.

It will only handle the message from the redis message queue.

This service shares the same image with the immich server, but the start command is different.

The rest of the configuration is the same as the immich server.

The 3rd service is the immich machine learning.

It will handle tasks like face detection and smart indexing.

It uses a different docker image.

This service mounts a cache volume for machine learning models and also requires the .env file.

The next service is redis and it serves as the message queue for immich.

The last service is the database.

Itā€™s a postgres database with the pgvecto extension

So itā€™s not using the vanilla postres image.

Here we set the database credentials using the environments.

They can be configured in the .env file.

You only need to modify the database password to a strong and random password.

The rest of the stuff can be left as is.

For the database service, we mount the pgdata volume to store the database files.

At the end, there are three volumes defined, and we already talk about them.

We also need to update our proxy rule for immich.

Iā€™m using caddy, so I add a rule to proxy the hostname immich.home.easyselfhost.com to the docker service immich-server with port 3001.

I recently posted a tutorial about using proxy for self-hosting. Check it out if you are interested.

To run the immich server, navigate to the directory with the docker compose on your server.

And then run docker compose up -d to start the docker compose.

Now our immich server is up and running.

We also need to refresh the proxy configuration.

For me Iā€™ll just restart the caddy server to let it reload.

Now we can go to the browser to set up immich.

Letā€™s go to the hostname we assign to immich.

For me, itā€™s immich.home.easyselfhost.com.

Now we can get started with immich.

Letā€™s first create an admin user.

And then login as that user we just created.

Choose the theme you like. Iā€™ll just keep the light theme.

Here you can choose to enable the storage template feature.

Immich can store your photos in a file structure that has date or other information.

And it has some predefined format that you can choose.

Personally, I donā€™t plan to access the files directly so Iā€™ll just disable it.

We will have the option to enable it later or change the format if we want.

After this, we complete the setup and enter the immich web app.

To import photos, the easiest way is to just drag and drop photos here.

But I think most people would want to import photos from their smartphones.

So letā€™s use the immich mobile app to upload photos here.

You can download it from the common mobile application stores listed on their website.

Iā€™m going to use the iOS app here but the Android app will be mostly the same.

Entering the app, we will first need to enter our immich server URL.

Thatā€™s the address we just typed in our browser.

Then, letā€™s login to our account.

Now we successfully logged in and can see the photos we just uploaded from the browser.

Letā€™s start setting up photo backup by clicking the cloud icon in the top right corner.

We need to give the immich app full access to our photos.

Then letā€™s select the albums for backup.

The recent album has all the photos on our phone, so Iā€™ll choose that.

Now we can click start backup and the app will start uploading photos to the immich server.

If we click the setting button on the top right, we can see the backup options.

Here we can turn on automatic foreground backup.

So when we open the app, it will automatically start uploading.

We can also turn on automatic background backup.

So the app can backup new photos even when the app is not opened.

After a while, the app will finish backing up.

You might need more time if you have more photos and videos.

Every photo will have an icon suggesting that itā€™s already backed up to the server.

Now letā€™s go back to the web app to explore more features.

We can see the photos uploaded from the phone show up here.

Resources