diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index a39f697..0000000 --- a/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM node:23-alpine - -COPY . /codered-astra - -WORKDIR /codered-astra - -RUN npm i - -EXPOSE 3000 - -RUN npm run format - -RUN npm run build - -CMD ["npm", "run", "host"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f61275f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,53 @@ +# docker-compose.yml +version: '3.8' + +services: + web-app: + build: + context: ./web-app + restart: always + ports: + - "80:3000" + environment: + # The connection string remains the same, but points to the 'mysql' service + - DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@mysql:3306/${MYSQL_DATABASE} + - RUST_ENGINE_URL=http://rust-engine:8000 + - GEMINI_API_KEY=${GEMINI_API_KEY} + depends_on: + - mysql # <-- Updated dependency + - rust-engine + + rust-engine: + build: + context: ./rust-engine + restart: always + environment: + - DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@mysql:3306/${MYSQL_DATABASE} + depends_on: + - mysql # <-- Updated dependency + + # --- Key Changes are in this section --- + mysql: # <-- Renamed service for clarity + image: mysql:8.0 # <-- CHANGED: Using the official MySQL 8.0 image + restart: always + environment: + - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + - MYSQL_DATABASE=${MYSQL_DATABASE} + - MYSQL_USER=${MYSQL_USER} + - MYSQL_PASSWORD=${MYSQL_PASSWORD} + volumes: + - mysql-data:/var/lib/mysql + + phpmyadmin: + image: phpmyadmin/phpmyadmin + restart: always + ports: + # CHANGED: Binds port 8080 to localhost ONLY. + - "127.0.0.1:8080:80" + environment: + - PMA_HOST=mysql + depends_on: + - mysql + +volumes: + mysql-data: # Renamed volume for clarity (optional but good practice) \ No newline at end of file diff --git a/rust-engine/Cargo.toml b/rust-engine/Cargo.toml new file mode 100644 index 0000000..e69de29 diff --git a/rust-engine/Dockerfile b/rust-engine/Dockerfile new file mode 100644 index 0000000..3c81632 --- /dev/null +++ b/rust-engine/Dockerfile @@ -0,0 +1,12 @@ +# rust-engine/Dockerfile +# --- Stage 1: Builder --- +FROM rust:1.7-slim as builder +WORKDIR /usr/src/app +COPY . . +RUN cargo build --release + +# --- Stage 2: Final Image --- +FROM debian:buster-slim +COPY --from=builder /usr/src/app/target/release/rust-engine /usr/local/bin/rust-engine +EXPOSE 8000 +CMD ["rust-engine"] \ No newline at end of file diff --git a/web-app/Dockerfile b/web-app/Dockerfile new file mode 100644 index 0000000..0788896 --- /dev/null +++ b/web-app/Dockerfile @@ -0,0 +1,22 @@ +# web-app/Dockerfile +FROM node:20-alpine + +WORKDIR /app + +# Copy package files first to leverage Docker's build cache +COPY package*.json ./ + +# Install all dependencies needed for the build +RUN npm install + +# Copy the rest of your application code +COPY . . + +# Run the build script to compile the React frontend +RUN npm run build + +# Expose the port your server will listen on +EXPOSE 3000 + +# The command to start your production server +CMD ["npm", "run", "host"] \ No newline at end of file diff --git a/eslint.config.js b/web-app/eslint.config.js similarity index 100% rename from eslint.config.js rename to web-app/eslint.config.js diff --git a/index.html b/web-app/index.html similarity index 100% rename from index.html rename to web-app/index.html diff --git a/jsconfig.json b/web-app/jsconfig.json similarity index 52% rename from jsconfig.json rename to web-app/jsconfig.json index ef46175..8fd87b4 100644 --- a/jsconfig.json +++ b/web-app/jsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { - "baseUrl": "src" + "baseUrl": "web-app/src" }, "include": [ - "src" + "web-app/src" ] } diff --git a/package-lock.json b/web-app/package-lock.json similarity index 100% rename from package-lock.json rename to web-app/package-lock.json diff --git a/package.json b/web-app/package.json similarity index 100% rename from package.json rename to web-app/package.json diff --git a/public/vite.svg b/web-app/public/vite.svg similarity index 100% rename from public/vite.svg rename to web-app/public/vite.svg diff --git a/src/App.jsx b/web-app/src/App.jsx similarity index 100% rename from src/App.jsx rename to web-app/src/App.jsx diff --git a/src/index.css b/web-app/src/index.css similarity index 100% rename from src/index.css rename to web-app/src/index.css diff --git a/src/main.jsx b/web-app/src/main.jsx similarity index 100% rename from src/main.jsx rename to web-app/src/main.jsx diff --git a/tailwind.config.js b/web-app/tailwind.config.js similarity index 100% rename from tailwind.config.js rename to web-app/tailwind.config.js diff --git a/vite.config.js b/web-app/vite.config.js similarity index 100% rename from vite.config.js rename to web-app/vite.config.js