diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..1eb0e0f55 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,65 @@ +{ + "name": "React Native (macOS)", + // Use a pre-built image with Node.js and common tools + "image": "mcr.microsoft.com/devcontainers/javascript-node:18", + // Or build from a Dockerfile for more control (uncomment the lines below) + // "build": { + // "dockerfile": "Dockerfile" + // }, + + // Add additional features (CLI tools) + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "17", + "installMaven": false, + "installGradle": true + }, + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/ruby:1": { + "version": "3.2" + } + }, + + // Configure environment variables (optional) + "containerEnv": { + "ANDROID_HOME": "/usr/local/android-sdk", + "JAVA_HOME": "/usr/local/sdkman/candidates/java/current" + }, + + // Run commands after the container is created + "postCreateCommand": "bash .devcontainer/post-create.sh", + + // Ports to forward (Metro bundler uses 8081) + "forwardPorts": [8081, 19000, 19001, 19002, 8081], + "portsAttributes": { + "8081": { + "label": "Metro Bundler", + "onAutoForward": "notify" + } + }, + + // Install VS Code extensions for React Native + "customizations": { + "vscode": { + "extensions": [ + "msjsdiag.vscode-react-native", + "msjsdiag.vscode-react-native-tools", + "dsznajder.es7-react-js-snippets", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "streetsidesoftware.code-spell-checker", + "vscjava.vscode-java-pack", + "redhat.vscode-xml", + "vadimcn.vscode-lldb" + ], + "settings": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "react-native-tools.showDevMenuOnStartup": true + } + } + }, + + // Use a non-root user to avoid permission issues + "remoteUser": "node" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 000000000..07429f6dd --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,30 @@ +version: '3.8' + +services: + app: + build: + context: . + dockerfile: Dockerfile # Your app's Dockerfile + volumes: + - ..:/workspace:cached + command: sleep infinity # Keep container alive + environment: + DATABASE_URL: postgresql://postgres:password@db:5432/mydb + depends_on: + - db + + db: + build: + context: ./postgres # Path to custom Dockerfile (or use image: postgres:15) + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password + POSTGRES_DB: mydb + ports: + - "5432:5432" # Expose port if needed + +volumes: + postgres-data: diff --git a/.devcontainer/dockerfile b/.devcontainer/dockerfile new file mode 100644 index 000000000..f741dd61b --- /dev/null +++ b/.devcontainer/dockerfile @@ -0,0 +1,28 @@ +# Start from the official Node.js 18 image (Debian-based) +FROM node:18 + +# Install Java 17 (OpenJDK) and other system dependencies +RUN apt-get update && apt-get install -y \ + openjdk-17-jdk \ + wget \ + unzip \ + git \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Set JAVA_HOME environment variable +ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 +ENV PATH=$JAVA_HOME/bin:$PATH + +# Install React Native CLI globally (optional) +RUN npm install -g react-native-cli + +# Install CocoaPods (requires Ruby) +RUN gem install cocoapods + +# Install Watchman (optional but recommended) +RUN apt-get update && apt-get install -y watchman + +# Set up a non-root user (optional but good practice) +RUN useradd -m -s /bin/bash node +USER node diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100644 index 000000000..48ffc664d --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -e + +echo "📲 Setting up Android SDK..." +mkdir -p $ANDROID_HOME/cmdline-tools +cd $ANDROID_HOME +wget https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip +unzip commandlinetools-linux-*.zip -d cmdline-tools +rm commandlinetools-linux-*.zip +mv cmdline-tools/cmdline-tools cmdline-tools/latest + +# Accept licenses +yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses + +# Install required SDK components +$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "platform-tools" "platforms;android-33" "build-tools;33.0.2"