From 877ef33a304c6717b244647a9580fc11a2ecedad Mon Sep 17 00:00:00 2001 From: CaseyDevs Date: Fri, 29 May 2026 12:29:59 +0100 Subject: [PATCH 1/3] chore: add basic docker config for development chore: add basic docker config for development misc: add missing updated --- .gitignore | 4 +- backend/.dockerignore | 7 +++ backend/Dockerfile | 17 +++++++ ...1__Fix_JobBoardApplication_FK_OnDelete.sql | 7 --- docker-compose.yml | 45 +++++++++++++++++++ frontend/.dockerignore | 6 +++ frontend/Dockerfile | 12 +++++ frontend/src/pages/RegisterPage.tsx | 2 +- frontend/src/pages/UpdateApplicationPage.tsx | 40 +++++++++-------- 9 files changed, 113 insertions(+), 27 deletions(-) create mode 100644 backend/.dockerignore create mode 100644 backend/Dockerfile delete mode 100644 backend/src/main/resources/db/migration/V1__Fix_JobBoardApplication_FK_OnDelete.sql create mode 100644 docker-compose.yml create mode 100644 frontend/.dockerignore create mode 100644 frontend/Dockerfile diff --git a/.gitignore b/.gitignore index ddd2db7..97d0202 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ .vscode/ .gradle/ bin -build \ No newline at end of file +build +.env +.env.prod \ No newline at end of file diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..440d435 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,7 @@ +.gradle +build +bin +*.iml +.idea +.vscode +.DS_Store diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..0d5b9df --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,17 @@ +FROM eclipse-temurin:21-jdk + +WORKDIR /app + +COPY gradlew gradlew +COPY gradle gradle +COPY build.gradle settings.gradle ./ +RUN chmod +x gradlew + +# Pre-fetch dependencies for faster startup +RUN ./gradlew --no-daemon dependencies || true + +COPY src src + +EXPOSE 8080 + +CMD ["./gradlew", "--no-daemon", "bootRun"] diff --git a/backend/src/main/resources/db/migration/V1__Fix_JobBoardApplication_FK_OnDelete.sql b/backend/src/main/resources/db/migration/V1__Fix_JobBoardApplication_FK_OnDelete.sql deleted file mode 100644 index 0b385c4..0000000 --- a/backend/src/main/resources/db/migration/V1__Fix_JobBoardApplication_FK_OnDelete.sql +++ /dev/null @@ -1,7 +0,0 @@ --- Drop the existing foreign key constraint on job_board_application.application_id -ALTER TABLE job_board_application DROP CONSTRAINT fkt974qraimxgxm7vebvs75qai8; - --- Recreate the foreign key with ON DELETE SET NULL -ALTER TABLE job_board_application -ADD CONSTRAINT fkt974qraimxgxm7vebvs75qai8 -FOREIGN KEY (application_id) REFERENCES application(id) ON DELETE SET NULL; diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2681a26 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +services: + db: + image: postgres:16 + env_file: + - ./backend/.env + environment: + POSTGRES_DB: applyflow + POSTGRES_USER: ${DB_USERNAME} + POSTGRES_PASSWORD: ${DB_PASSWORD} + ports: + - "5432:5432" + volumes: + - db_data:/var/lib/postgresql/data + + backend: + build: + context: ./backend + env_file: + - ./backend/.env + environment: + DB_URL: jdbc:postgresql://db:5432/applyflow + ports: + - "8080:8080" + depends_on: + - db + volumes: + - ./backend:/app + - gradle_cache:/root/.gradle + working_dir: /app + command: ["./gradlew", "--no-daemon", "bootRun"] + + frontend: + build: + context: ./frontend + ports: + - "5173:5173" + depends_on: + - backend + volumes: + - ./frontend:/app + - /app/node_modules + +volumes: + db_data: + gradle_cache: diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000..84407f7 --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,6 @@ +node_modules +.dist +build +.vscode +.idea +.DS_Store diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..43b2837 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,12 @@ +FROM node:20-alpine + +WORKDIR /app + +COPY package*.json ./ +RUN npm install + +COPY . . + +EXPOSE 5173 + +CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "5173"] diff --git a/frontend/src/pages/RegisterPage.tsx b/frontend/src/pages/RegisterPage.tsx index 1904119..72b38e5 100644 --- a/frontend/src/pages/RegisterPage.tsx +++ b/frontend/src/pages/RegisterPage.tsx @@ -1,6 +1,6 @@ import { useState } from "react"; import { registerUser } from "../api/auth/register"; -import { Link, useNavigate } from "react-router-dom"; +import { Link } from "react-router-dom"; import styles from "./Auth.module.css"; import { useTimedError } from "../hooks/useTimedError"; diff --git a/frontend/src/pages/UpdateApplicationPage.tsx b/frontend/src/pages/UpdateApplicationPage.tsx index 6df8ebb..17b2125 100644 --- a/frontend/src/pages/UpdateApplicationPage.tsx +++ b/frontend/src/pages/UpdateApplicationPage.tsx @@ -3,7 +3,7 @@ import type { UpdateApplicationRequest } from "../types/Application"; import { createCompany, getAllCompanies } from "../api/companiesApi"; import { getApplicationById, updateApplication } from "../api/applicationApi"; import { useNavigate, useParams } from "react-router-dom"; -import type { CompanyRequest, CompanyResponse } from "../types/Company"; +import type { CompanyRequest } from "../types/Company"; import type { ApplicationStatus } from "../types/ApplicationStatus"; import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import styles from "./Forms.module.css"; @@ -12,9 +12,9 @@ export default function UpdateApplicationPage() { const [updatedTitle, setUpdatedTitle] = useState(""); const [updatedUrl, setUpdatedUrl] = useState(""); const [updatedStatus, setUpdatesStatus] = useState(null); + const [updatedLocation, setUpdatedLocation] = useState(null); const [selectedCompanyId, setSelectedCompanyId] = useState(null); const [newCompanyName, setNewCompanyName] = useState(""); - const [location, setLocation] = useState(null); const [showNewCompanyForm, setShowNewCompanyForm] = useState(false); const navigate = useNavigate(); @@ -30,7 +30,7 @@ export default function UpdateApplicationPage() { const hasValidJobBoardId = thisJobBoardId !== null && Number.isFinite(thisJobBoardId); // ensure job board id is always valid // Fetch companies list - const { data: companiesData, isLoading: companiesLoading, error: companiesError } = useQuery({ + const { data: companiesData } = useQuery({ queryKey: ["companies"], queryFn: getAllCompanies, }); @@ -50,19 +50,19 @@ export default function UpdateApplicationPage() { setUpdatedTitle(application.title); setUpdatedUrl(application.url); setUpdatesStatus(application.status); + setUpdatedLocation(application.location); setSelectedCompanyId(application.companyId); } }, [application]); // Mutation for creating a company const createCompanyMutation = useMutation({ - mutationFn: (data: { name: string; location: string | null }) => - createCompany(data as CompanyRequest), + mutationFn: (data: CompanyRequest) => + createCompany(data), onSuccess: () => { // Invalidate and refetch companies list queryClient.invalidateQueries({ queryKey: ["companies"] }); setNewCompanyName(""); - setLocation(null); setShowNewCompanyForm(false); }, }); @@ -86,7 +86,7 @@ export default function UpdateApplicationPage() { async function handleAddCompany() { if (!newCompanyName) return; - createCompanyMutation.mutate({ name: newCompanyName, location }); + createCompanyMutation.mutate({ name: newCompanyName, rating: null }); } async function handleSubmit(e: React.SubmitEvent) { @@ -96,6 +96,7 @@ export default function UpdateApplicationPage() { const updatedApplication: UpdateApplicationRequest = { title: updatedTitle, url: updatedUrl, + location: updatedLocation, companyId: selectedCompanyId, status: updatedStatus, }; @@ -182,6 +183,20 @@ export default function UpdateApplicationPage() { +
+ + setUpdatedLocation(e.target.value)} + required + /> +
+
{companies && companies.length > 0 ? ( @@ -223,17 +238,6 @@ export default function UpdateApplicationPage() { onChange={e => setNewCompanyName(e.target.value)} />
-
- - setLocation(e.target.value)} - /> -