Extend existing dockerfiles/composes

This commit is contained in:
Min Idzelis 2025-05-01 14:17:42 +00:00
parent f99d4cf6dd
commit 974953e371
8 changed files with 93 additions and 44 deletions

View File

@ -1,8 +0,0 @@
services:
immich-devcontainer:
build:
dockerfile: Dockerfile
extra_hosts:
- 'host.docker.internal:host-gateway'
volumes:
- ..:/immich:cached

View File

@ -1,16 +0,0 @@
ARG BASEIMAGE=ghcr.io/immich-app/base-server-dev:202503182202@sha256:45ae044b64a7b518f8d94fa4de718090c1c7689d516ac2ac0976a5331eaeb396
FROM ${BASEIMAGE} AS dev
RUN apt-get install inetutils-ping sudo -y
RUN usermod -aG sudo node
RUN echo "node ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN mkdir -p /workspaces/immich
RUN chown node -R /workspaces
RUN mkdir /immich-devcontainer && chown node -R /immich-devcontainer
COPY --chmod=777 ./.devcontainer/server/common.sh /immich-devcontainer/common.sh
COPY --chmod=777 ./.devcontainer/server/postCreate.sh /immich-devcontainer/postCreate.sh
COPY --chmod=777 ./.devcontainer/server/startNestApiServer.sh /immich-devcontainer/startNestApiServer.sh
COPY --chmod=777 ./.devcontainer/server/startViteWebServer.sh /immich-devcontainer/startViteWebServer.sh

View File

@ -1,7 +1,9 @@
services:
immich-devcontainer-server:
build:
dockerfile: ./.devcontainer/server/Dockerfile
dockerfile: server/Dockerfile
target: dev-container
context: ../..
hostname: immich-devcontainer-server
extra_hosts:
@ -24,13 +26,19 @@ services:
- ${UPLOAD_LOCATION}:/workspaces/immich/server/upload
immich-devcontainer-redis:
image: redis:6.2-alpine@sha256:148bb5411c184abd288d9aaed139c98123eeb8824c5d3fce03cf721db58066d8
extends:
file: ../../docker/docker-compose.dev.yml
service: redis
container_name: immich-devcontainer-redis
command: redis-server --port 6400
healthcheck:
test: redis-cli ping || exit 1
test: redis-cli -p 6400 ping || exit 1
immich-devcontainer-database:
image: tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:739cdd626151ff1f796dc95a6591b55a714f341c737e27f045019ceabf8e8c52
extends:
file: ../../docker/docker-compose.dev.yml
service: database
container_name: immich-devcontainer-database
env_file:
- .env
environment:

View File

@ -13,14 +13,14 @@ sudo chown node -R "${IMMICH_WORKSPACE}/.vscode" \
"${IMMICH_WORKSPACE}/web/node_modules" \
"${IMMICH_WORKSPACE}/web/dist"
echo "Installing dependencies (server)"
echo npm --prefix "${IMMICH_WORKSPACE}/server" install
npm --prefix "${IMMICH_WORKSPACE}/server" install
run_cmd() {
echo "$@"
"$@"
}
echo "Installing dependencies (web)"
echo npm --prefix "${IMMICH_WORKSPACE}/open-api/typescript-sdk" install
npm --prefix "${IMMICH_WORKSPACE}/open-api/typescript-sdk" install
echo npm --prefix "${IMMICH_WORKSPACE}/open-api/typescript-sdk" run build
npm --prefix "${IMMICH_WORKSPACE}/open-api/typescript-sdk" run build
echo npm --prefix "${IMMICH_WORKSPACE}/web" install
npm --prefix "${IMMICH_WORKSPACE}/web" install
echo "Installing dependencies"
run_cmd npm --prefix "${IMMICH_WORKSPACE}/server" install
run_cmd npm --prefix "${IMMICH_WORKSPACE}/open-api/typescript-sdk" install
run_cmd npm --prefix "${IMMICH_WORKSPACE}/open-api/typescript-sdk" run build
run_cmd npm --prefix "${IMMICH_WORKSPACE}/web" install

View File

@ -18,7 +18,6 @@
"name": "Immich Workers",
"remoteRoot": "/usr/src/app",
"localRoot": "${workspaceFolder}/server"
}
]
}

22
docker/.env Normal file
View File

@ -0,0 +1,22 @@
# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables
# The location where your uploaded files are stored
UPLOAD_LOCATION=./library
# The location where your database files are stored. Network shares are not supported for the database
DB_DATA_LOCATION=./postgres
# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this list: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
# TZ=Etc/UTC
# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release
# Connection secret for postgres. You should change it to a random password
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
DB_PASSWORD=postgres
# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

View File

@ -13,7 +13,7 @@ The Dev Container is a fully featured dev environment. It is a portable way, usi
[More info on dev containers here](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers)
### Details
## Configuration
The Immich dev container runs the web and server in one container, and redis and ML each in their own container.
@ -29,11 +29,11 @@ In non-cloud environments, you can optionally use host filesystem paths instead
4. Select "Immich - Backend and Frontend"
5. Wait a while - after the builds are done, the server and web processes will be started as tasks, and the browser will be opened (once) to the front page.
## Configuring Database and Upload paths to the host
### Configuring Database and Upload paths to the host
ENV VARs can use to control the location of the upload and the database paths.
### UPLOAD_LOCATION
#### UPLOAD_LOCATION
The default for `UPLOAD_LOCATION` is `vol-upload` which is a volume mount.
@ -45,7 +45,7 @@ To use a bind mount instead, simply set `UPLOAD_LOCATION` to an **absolute** pat
export UPLOAD_LOCATION=/data/my/upload/path
```
### DB_DATA_LOCATION
#### DB_DATA_LOCATION
The default for `DB_DATA_LOCATION` is `vol-database` which is a volume mount.
@ -57,7 +57,7 @@ To use a bind mount instead, simply set `DB_DATA_LOCATION` to an **absolute** pa
export DB_DATA_LOCATION=/data/my/upload/path
```
### Other Variables
#### Other Variables
Its unlikely, but in case you modified the username/password of the database, you can control these values using the following ENV VARs:
@ -68,3 +68,33 @@ export DB_DATABASE_NAME=immich
```
This must be added to the `.bash_profile` if your using bash, or equivalent for other shells.
### SSH Keys and Commit Signing
This section applies if you are using SSH Keys to access GitHub. In order to allow git from inside the devcontainer to access GitHub using your existing SSH keys, ensure that you have a SSH Agent running, and that SSH agent forwarding is allowed.
For instructions, see the [guide here.](https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials)
You can also use this SSH key as a signing key. To configure this, see the [guide here.](https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key#telling-git-about-your-ssh-key)
## Workflow
Please ensure you've read the [setup](/docs/developer/setup) information first.
After you've configured or reviewed the environment variables as mentioned above, then you are ready to start development.
By default, the devcontainer will automatically perform a few tasks whenever it starts.
1) Runs `postCreate.sh` - this bash script will adjust permissions to the `node` user that the devcontainer runs as. It will also run `npm i` and `npm run build` in all of the packages: `open-api/typescript-sdk`, `web`, and `server`.
2. VSCode will autorun the `Immich Server and Web` task defined in `tasks.json`. This task depends on `Immich Web Server (Vite)` and `Immich API Server (Nest)`, which will both be started automatically.
3. VSCode will automatically forward the web ports, and the debug ports from each process. The first time the web server is started, a browser will automatically be opened on the `/` URL of the server (both in local and cloud environments)
The `Immich API Server (Nest)` task runs the "API server", watching and compiling chnages in the `/server` folder.
The `Immich Web Server (Vite)` task runs the "Web server", watching and compiling chnages in the `/web` folder. The web server will automatically proxy the upstream `/api` server in this development.
These two tasks combined replace the command
```
make dev
```
from the non devcontainer developer workflow.

View File

@ -16,6 +16,20 @@ ENV PATH="${PATH}:/usr/src/app/bin" \
NVIDIA_VISIBLE_DEVICES=all
ENTRYPOINT ["tini", "--", "/bin/sh"]
FROM dev AS dev-container
RUN apt-get install inetutils-ping sudo -y
RUN usermod -aG sudo node
RUN echo "node ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN mkdir -p /workspaces/immich
RUN chown node -R /workspaces
RUN mkdir /immich-devcontainer && chown node -R /immich-devcontainer
COPY --chmod=777 ../.devcontainer/server/common.sh /immich-devcontainer/common.sh
COPY --chmod=777 ../.devcontainer/server/postCreate.sh /immich-devcontainer/postCreate.sh
COPY --chmod=777 ../.devcontainer/server/startNestApiServer.sh /immich-devcontainer/startNestApiServer.sh
COPY --chmod=777 ../.devcontainer/server/startViteWebServer.sh /immich-devcontainer/startViteWebServer.sh
FROM dev AS prod