diff --git a/.devcontainer/.gitignore b/.devcontainer/.gitignore new file mode 100644 index 0000000000000..6bf3b5d9e5c1d --- /dev/null +++ b/.devcontainer/.gitignore @@ -0,0 +1,2 @@ +.env +library \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e19fe74643957..71facefafd141 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,2 +1,16 @@ -ARG BASEIMAGE=mcr.microsoft.com/devcontainers/typescript-node:22@sha256:dc2c3654370fe92a55daeefe9d2d95839d85bdc1f68f7fd4ab86621f49e5818a +ARG BASEIMAGE=mcr.microsoft.com/devcontainers/typescript-node:22 FROM ${BASEIMAGE} + +# Flutter SDK +# https://flutter.dev/docs/development/tools/sdk/releases?tab=linux +ENV FLUTTER_CHANNEL="stable" +ENV FLUTTER_VERSION="3.24.5" +ENV FLUTTER_HOME=/flutter +ENV PATH=${PATH}:${FLUTTER_HOME}/bin + +# Flutter SDK +RUN mkdir -p ${FLUTTER_HOME} \ + && 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 \ + && tar -xf flutter.tar.xz --strip-components=1 -C ${FLUTTER_HOME} \ + && rm flutter.tar.xz \ + && chown -R 1000:1000 ${FLUTTER_HOME} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b297f9a2d8cc1..b87950ce24d41 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,20 +1,50 @@ { - "name": "Immich devcontainers", - "build": { - "dockerfile": "Dockerfile", - "args": { - "BASEIMAGE": "mcr.microsoft.com/devcontainers/typescript-node:22" - } - }, + "name": "Immich", + "service": "immich-devcontainer", + "dockerComposeFile": [ + "docker-compose.yml", + "../docker/docker-compose.dev.yml" + ], "customizations": { "vscode": { + "settings": { + "dart.flutterSdkPath": "/flutter", + "editor.formatOnSave": true, + "[javascript][typescript][css]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.tabSize": 2, + "editor.formatOnSave": true + }, + "[svelte]": { + "editor.defaultFormatter": "svelte.svelte-vscode", + "editor.tabSize": 2 + }, + "svelte.enable-ts-plugin": true, + "eslint.validate": ["javascript", "svelte"], + "[dart]": { + "editor.formatOnSave": true, + "editor.selectionHighlight": false, + "editor.suggest.snippetsPreventQuickSuggestions": false, + "editor.suggestSelection": "first", + "editor.tabCompletion": "onlySnippets", + "editor.wordBasedSuggestions": "off", + "editor.defaultFormatter": "Dart-Code.dart-code" + } + }, "extensions": [ + "Dart-Code.dart-code", + "Dart-Code.flutter", + "dbaeumer.vscode-eslint", + "dcmdev.dcm-vscode-extension", + "esbenp.prettier-vscode", "svelte.svelte-vscode" ] } }, "forwardPorts": [], - "postCreateCommand": "make install-all", - "remoteUser": "node" + "initializeCommand": "bash .devcontainer/scripts/initializeCommand.sh", + "onCreateCommand": "bash .devcontainer/scripts/onCreateCommand.sh", + "overrideCommand": true, + "workspaceFolder": "/immich", + "remoteUser": "node" } - diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000000000..25719641d2ddf --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,8 @@ +services: + immich-devcontainer: + build: + dockerfile: Dockerfile + extra_hosts: + - 'host.docker.internal:host-gateway' + volumes: + - ..:/immich:cached diff --git a/.devcontainer/scripts/initializeCommand.sh b/.devcontainer/scripts/initializeCommand.sh new file mode 100644 index 0000000000000..4e73bdccfdf0f --- /dev/null +++ b/.devcontainer/scripts/initializeCommand.sh @@ -0,0 +1,4 @@ +# If .env file does not exist, create it by copying example.env from the docker folder +if [ ! -f ".devcontainer/.env" ]; then + cp docker/example.env .devcontainer/.env +fi diff --git a/.devcontainer/scripts/onCreateCommand.sh b/.devcontainer/scripts/onCreateCommand.sh new file mode 100644 index 0000000000000..f29c2227c720e --- /dev/null +++ b/.devcontainer/scripts/onCreateCommand.sh @@ -0,0 +1,24 @@ +# Enable multiarch for arm64 if necessary +if [ "$(dpkg --print-architecture)" = "arm64" ]; then + sudo dpkg --add-architecture amd64 && \ + sudo apt-get update && \ + sudo apt-get install -y --no-install-recommends \ + qemu-user-static \ + libc6:amd64 \ + libstdc++6:amd64 \ + libgcc1:amd64 +fi + +# Install DCM +wget -qO- https://dcm.dev/pgp-key.public | sudo gpg --dearmor -o /usr/share/keyrings/dcm.gpg +sudo 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 + +sudo apt-get update +sudo apt-get install dcm + +dart --disable-analytics + +# Install immich +cd /immich +make install-all +