Skip to content

Commit 5c303e4

Browse files
committed
feat: devcontainers
1 parent 5699034 commit 5c303e4

29 files changed

+521
-337
lines changed

.devcontainer/.gitignore

-2
This file was deleted.

.devcontainer/Dockerfile

-16
This file was deleted.

.devcontainer/devcontainer.json

+35-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,46 @@
11
{
2-
"name": "Immich",
3-
"service": "immich-devcontainer",
4-
"dockerComposeFile": [
5-
"docker-compose.yml",
6-
"../docker/docker-compose.dev.yml"
7-
],
2+
"name": "Immich - Backend and Frontend",
3+
"service": "immich-devcontainer-server",
4+
"dockerComposeFile": ["server/docker-compose.yml"],
85
"customizations": {
96
"vscode": {
107
"extensions": [
11-
"Dart-Code.dart-code",
12-
"Dart-Code.flutter",
138
"dbaeumer.vscode-eslint",
14-
"dcmdev.dcm-vscode-extension",
159
"esbenp.prettier-vscode",
16-
"svelte.svelte-vscode"
10+
"svelte.svelte-vscode",
11+
"ms-vscode-remote.remote-containers",
12+
"foxundermoon.shell-format",
13+
"timonwong.shellcheck",
14+
"rvest.vs-code-prettier-eslint",
15+
"bluebrown.yamlfmt",
16+
"vkrishna04.cspell-sync",
17+
"vitest.explorer",
18+
"ms-playwright.playwright"
1719
]
1820
}
1921
},
20-
"forwardPorts": [],
21-
"initializeCommand": "bash .devcontainer/scripts/initializeCommand.sh",
22-
"onCreateCommand": "bash .devcontainer/scripts/onCreateCommand.sh",
22+
"forwardPorts": [3000, 9231, 9230, 2283],
23+
"portsAttributes": {
24+
"3000": {
25+
"label": "Immich - Frontend HTTP",
26+
"description": "The frontend of the Immich project",
27+
"onAutoForward": "openBrowserOnce"
28+
},
29+
"2283": {
30+
"label": "Immich - API Server - HTTP",
31+
"description": "The API server of the Immich project"
32+
},
33+
"9231": {
34+
"label": "Immich - API Server - DEBUG",
35+
"description": "The API server of the Immich project"
36+
},
37+
"9230": {
38+
"label": "Immich - Workers - DEBUG",
39+
"description": "The workers of the Immich project"
40+
}
41+
},
2342
"overrideCommand": true,
24-
"workspaceFolder": "/immich",
25-
"remoteUser": "node"
43+
"workspaceFolder": "/workspaces/immich",
44+
"remoteUser": "node",
45+
"postCreateCommand": "/workspaces/postCreate.sh"
2646
}

.devcontainer/docker-compose.yml

-8
This file was deleted.

.devcontainer/ml/.env

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables
2+
3+
# The location where your uploaded files are stored
4+
UPLOAD_LOCATION=upload-volume
5+
6+
# The location where your database files are stored
7+
DB_DATA_LOCATION=db-volume
8+
9+
# 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
10+
# TZ=Etc/UTC
11+
12+
# Connection secret for postgres. You should change it to a random password
13+
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
14+
DB_PASSWORD=postgres
15+
16+
# The values below this line do not need to be changed
17+
###################################################################################
18+
DB_USERNAME=postgres
19+
DB_DATABASE_NAME=immich

.devcontainer/ml/devcontainer.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "Immich - Machine Learning",
3+
"service": "immich-machine-learning",
4+
"dockerComposeFile": ["docker-compose.yml"],
5+
"customizations": {
6+
"vscode": {
7+
"extensions": [
8+
"ms-python.python","ms-python.debugpy","KevinRose.vsc-python-indent"
9+
]
10+
}
11+
},
12+
"forwardPorts": [],
13+
"overrideCommand": true,
14+
"workspaceFolder": "/workspaces/immich",
15+
"remoteUser": "node"
16+
17+
}

.devcontainer/ml/docker-compose.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
immich-machine-learning:
3+
image: immich-machine-learning-dev:latest
4+
build:
5+
context: ../../machine-learning
6+
dockerfile: Dockerfile
7+
target: devcontainer
8+
hostname: immich-machine-learning
9+
volumes:
10+
# bind mount host to /workspaces/immich
11+
- ../..:/workspaces/immich
12+
- model-cache:/cache
13+
14+
volumes:
15+
model-cache:

.devcontainer/mobile/.env

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables
2+
3+
# The location where your uploaded files are stored
4+
UPLOAD_LOCATION=upload-volume
5+
6+
# The location where your database files are stored
7+
DB_DATA_LOCATION=db-volume
8+
9+
# 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
10+
# TZ=Etc/UTC
11+
12+
# Connection secret for postgres. You should change it to a random password
13+
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
14+
DB_PASSWORD=postgres
15+
16+
# The values below this line do not need to be changed
17+
###################################################################################
18+
DB_USERNAME=postgres
19+
DB_DATABASE_NAME=immich

.devcontainer/mobile/Dockerfile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
ARG BASEIMAGE=ghcr.io/immich-app/base-server-dev:202503182202@sha256:45ae044b64a7b518f8d94fa4de718090c1c7689d516ac2ac0976a5331eaeb396
2+
FROM ${BASEIMAGE} AS dev
3+
4+
# Flutter SDK
5+
# https://flutter.dev/docs/development/tools/sdk/releases?tab=linux
6+
ENV FLUTTER_CHANNEL="stable"
7+
ENV FLUTTER_VERSION="3.29.2"
8+
ENV FLUTTER_HOME=/flutter
9+
ENV PATH=${PATH}:${FLUTTER_HOME}/bin
10+
11+
RUN apt-get install inetutils-ping sudo
12+
RUN usermod -aG sudo node
13+
RUN echo "node ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
14+
RUN mkdir -p /workspaces/immich
15+
RUN chown node -R /workspaces
16+
17+
# Flutter SDK
18+
RUN mkdir -p ${FLUTTER_HOME} \
19+
&& curl -C - --output flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/${FLUTTER_CHANNEL}/linux/flutter_linux_${FLUTTER_VERSION}-${FLUTTER_CHANNEL}.tar.xz \
20+
&& tar -xf flutter.tar.xz --strip-components=1 -C ${FLUTTER_HOME} \
21+
&& rm flutter.tar.xz \
22+
&& chown -R node ${FLUTTER_HOME}
23+
24+
USER node
25+
RUN sudo apt-get update \
26+
&& wget -qO- https://dcm.dev/pgp-key.public | sudo gpg --dearmor -o /usr/share/keyrings/dcm.gpg \
27+
&& echo 'deb [signed-by=/usr/share/keyrings/dcm.gpg arch=amd64] https://dcm.dev/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list \
28+
&& sudo apt-get update \
29+
&& sudo apt-get install dcm -y
30+
31+
RUN dart --disable-analytics
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "Immich - Mobile",
3+
"service": "immich-mobile",
4+
"dockerComposeFile": ["docker-compose.yml"],
5+
"customizations": {
6+
"vscode": {
7+
"extensions": [
8+
"Dart-Code.dart-code",
9+
"Dart-Code.flutter",
10+
"dcmdev.dcm-vscode-extension",
11+
"esbenp.prettier-vscode"
12+
]
13+
}
14+
},
15+
"forwardPorts": [],
16+
"overrideCommand": true,
17+
"workspaceFolder": "/workspaces/immich",
18+
"remoteUser": "node",
19+
"postCreateCommand": "/workspaces/immich/.devcontainer/mobile/postCreate.sh"
20+
}
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
services:
2+
immich-mobile:
3+
build:
4+
dockerfile: Dockerfile
5+
hostname: immich-devcontainer-mobile
6+
extra_hosts:
7+
- 'host.docker.internal:host-gateway'
8+
volumes:
9+
# by default, bind mount host to /workspaces/immich
10+
- ../..:/workspaces/immich
11+
- ./vscode:/workspaces/immich/.vscode
12+
- cli_node_modules:/workspaces/immich/cli/node_modules
13+
- e2e_node_modules:/workspaces/immich/e2e/node_modules
14+
- open_api_node_modules:/workspaces/immich/open-api/typescript-sdk/node_modules
15+
- server_node_modules:/workspaces/immich/server/node_modules
16+
- web_node_modules:/workspaces/immich/web/node_modules
17+
- ${UPLOAD_LOCATION}:/workspaces/immich/server/upload
18+
19+
volumes:
20+
cli_node_modules:
21+
e2e_node_modules:
22+
open_api_node_modules:
23+
server_node_modules:
24+
web_node_modules:
25+
immich:
26+
upload-volume:
27+
db-volume:

.devcontainer/mobile/postCreate.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Enable multiarch for arm64 if necessary
4+
if [ "$(dpkg --print-architecture)" = "arm64" ]; then
5+
sudo dpkg --add-architecture amd64 &&
6+
sudo apt-get update &&
7+
sudo apt-get install -y --no-install-recommends \
8+
qemu-user-static \
9+
libc6:amd64 \
10+
libstdc++6:amd64 \
11+
libgcc1:amd64
12+
fi
13+
14+
dart --disable-analytics
15+
16+
export IMMICH_PORT="${DEV_SERVER_PORT:-2283}"
17+
export DEV_PORT="${DEV_PORT:-3000}"
18+
19+
sudo chown node -R /workspaces/immich/.vscode \
20+
/workspaces/immich/cli/node_modules \
21+
/workspaces/immich/e2e/node_modules \
22+
/workspaces/immich/open-api/typescript-sdk/node_modules \
23+
/workspaces/immich/server/node_modules \
24+
/workspaces/immich/web/node_modules \
25+
/workspaces/immich/server/upload
26+
27+
echo "Installing dependencies (server)"
28+
npm --prefix /workspaces/immich/server install
29+
30+
echo "Installing dependencies (web)"
31+
npm --prefix /workspaces/immich/open-api/typescript-sdk install
32+
npm --prefix /workspaces/immich/open-api/typescript-sdk run build
33+
npm --prefix /workspaces/immich/web install

.devcontainer/scripts/initializeCommand.sh

-6
This file was deleted.

.devcontainer/scripts/onCreateCommand.sh

-25
This file was deleted.

.devcontainer/server/.env

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables
2+
3+
# The location where your uploaded files are stored
4+
UPLOAD_LOCATION=upload-volume
5+
6+
# The location where your database files are stored
7+
DB_DATA_LOCATION=db-volume
8+
9+
# 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
10+
# TZ=Etc/UTC
11+
12+
# Connection secret for postgres. You should change it to a random password
13+
# Please use only the characters `A-Za-z0-9`, without special characters or spaces
14+
DB_PASSWORD=postgres
15+
16+
# The values below this line do not need to be changed
17+
###################################################################################
18+
DB_USERNAME=postgres
19+
DB_DATABASE_NAME=immich

.devcontainer/server/Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ARG BASEIMAGE=ghcr.io/immich-app/base-server-dev:202503182202@sha256:45ae044b64a7b518f8d94fa4de718090c1c7689d516ac2ac0976a5331eaeb396
2+
FROM ${BASEIMAGE} AS dev
3+
4+
RUN apt-get install inetutils-ping sudo
5+
RUN usermod -aG sudo node
6+
RUN echo "node ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
7+
RUN mkdir -p /workspaces/immich
8+
RUN chown node -R /workspaces
9+
10+
COPY --chmod=777 ./.devcontainer/server/common.sh /workspaces/common.sh
11+
COPY --chmod=777 ./.devcontainer/server/postCreate.sh /workspaces/postCreate.sh
12+
COPY --chmod=777 ./.devcontainer/server/startServer.sh /workspaces/startServer.sh
13+
COPY --chmod=777 ./.devcontainer/server/startWeb.sh /workspaces/startWeb.sh
14+
15+
COPY ./.devcontainer/ /workspaces/immich/.devcontainer/
16+
# add postCreate here
17+
# modify postCreate to search for which immich is active, and perform the changes needed

.devcontainer/server/common.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
export IMMICH_PORT="${DEV_SERVER_PORT:-2283}"
3+
export DEV_PORT="${DEV_PORT:-3000}"
4+
5+
# search for immich directory inside workspace.
6+
# /workspaces/immich is the bind mount, but other directories can be mounted if runing
7+
# Devcontainer: Clone [repository|pull request] in container volumne
8+
WORKSPACES_DIR="/workspaces"
9+
IMMICH_DIR="$WORKSPACES_DIR/immich"
10+
11+
# Find directories excluding /workspaces/immich
12+
mapfile -t other_dirs < <(find "$WORKSPACES_DIR" -mindepth 1 -maxdepth 1 -type d ! -path "$IMMICH_DIR")
13+
14+
if [ ${#other_dirs[@]} -gt 1 ]; then
15+
echo "Error: More than one directory found in $WORKSPACES_DIR other than $IMMICH_DIR."
16+
exit 1
17+
elif [ ${#other_dirs[@]} -eq 1 ]; then
18+
export IMMICH_WORKSPACE="${other_dirs[0]}"
19+
else
20+
export IMMICH_WORKSPACE="$IMMICH_DIR"
21+
fi
22+
23+
echo "Found immich workspace in $IMMICH_WORKSPACE"

0 commit comments

Comments
 (0)