From befb956e35d602f8c16fee97675c2ea7a02a4100 Mon Sep 17 00:00:00 2001 From: Majk Shkurti Date: Wed, 25 Oct 2023 17:08:32 +0200 Subject: [PATCH] fix: dockerfile --- .env.docker | 1 - .husky/.gitignore | 0 .husky/commit-msg | 2 +- .husky/pre-commit | 2 +- .../settings/settings/PersonalPreferences.tsx | 181 ------------------ .../(dashboard)/settings/settings/Profile.tsx | 108 ----------- .../(dashboard)/settings/settings/layout.tsx | 28 --- apps/goat/public/assets/poi-icons/circle.svg | 3 - apps/goat/public/assets/poi-icons/star.svg | 3 - apps/web/Dockerfile | 12 +- .../dashboard/common/FoldersTreeView.tsx | 4 +- apps/web/components/modals/DatasetUpload.tsx | 8 +- apps/web/components/modals/Project.tsx | 2 +- apps/web/entrypoint.sh | 26 +++ apps/web/lib/api/folders.ts | 4 +- apps/web/lib/validations/folder.ts | 5 +- docker-compose.yml | 12 ++ package.json | 2 +- 18 files changed, 61 insertions(+), 342 deletions(-) delete mode 100644 .env.docker delete mode 100644 .husky/.gitignore delete mode 100644 apps/goat/app/[lng]/(dashboard)/settings/settings/PersonalPreferences.tsx delete mode 100644 apps/goat/app/[lng]/(dashboard)/settings/settings/Profile.tsx delete mode 100644 apps/goat/app/[lng]/(dashboard)/settings/settings/layout.tsx delete mode 100644 apps/goat/public/assets/poi-icons/circle.svg delete mode 100644 apps/goat/public/assets/poi-icons/star.svg create mode 100755 apps/web/entrypoint.sh create mode 100644 docker-compose.yml diff --git a/.env.docker b/.env.docker deleted file mode 100644 index 15461b22..00000000 --- a/.env.docker +++ /dev/null @@ -1 +0,0 @@ -NEXT_PUBLIC_WEBAPP_URL=http://localhost:3000 \ No newline at end of file diff --git a/.husky/.gitignore b/.husky/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/.husky/commit-msg b/.husky/commit-msg index 802183cc..c160a771 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -cd ./app/client && npx --no -- commitlint --edit ${1} +npx --no -- commitlint --edit ${1} diff --git a/.husky/pre-commit b/.husky/pre-commit index e331949d..58993aae 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -cd ./app/client && pnpm lint +pnpm lint diff --git a/apps/goat/app/[lng]/(dashboard)/settings/settings/PersonalPreferences.tsx b/apps/goat/app/[lng]/(dashboard)/settings/settings/PersonalPreferences.tsx deleted file mode 100644 index ee4855b3..00000000 --- a/apps/goat/app/[lng]/(dashboard)/settings/settings/PersonalPreferences.tsx +++ /dev/null @@ -1,181 +0,0 @@ -"use client"; - -import React from "react"; -import { makeStyles } from "@/lib/theme"; -import { Box } from "@mui/material"; -import { v4 } from "uuid"; -import { SelectField } from "@p4b/ui/components/Inputs"; -import type { Option } from "@p4b/types/atomicComponents"; -import { useTranslation } from "react-i18next"; -import { useRouter, usePathname } from "next/navigation"; -import { Card } from "@p4b/ui/components/Surfaces"; -import { Typography, Divider, Switch } from "@mui/material"; - -function removeNrOfElementsFromArray(pathname: string, len: number) { - const parts = pathname.split("/"); - if (parts.length >= len) { - parts.splice(0, len); - } - return parts.join("/"); -} - -const PersonalPreferences = () => { - const { classes } = useStyles(); - - const { i18n } = useTranslation("home"); - const router = useRouter(); - const pathname = usePathname(); - - const options: Option[] = [ - { - label: "Eng", - value: "en", - }, - { - label: "Deu", - value: "de", - }, - ]; - - const changeLanguage = (locale: string) => { - i18n.changeLanguage(locale); - const pathnameWithoutLocale = removeNrOfElementsFromArray(pathname, 2); - router.push(`/${locale}/${pathnameWithoutLocale}`); - }; - - return ( -
- - - - Language - - Manage the sites language - - - - - } - > - - Language - changeLanguage(value)} - defaultValue={i18n.language} - options={options.map((option) => ({ - name: option.label, - value: option.value, - }))} - label="" - size="small" - /> - - - - - Notification - - Manage the notification settings & modes - - - - - } - > - - Email - - - - Phone - - - - - - Theme - - Chose between Dark & Light modes - - - - - } - > - - Dark - - - - -
- ); -}; - -const useStyles = makeStyles({ name: { PersonalPreferences } })((theme) => ({ - label: { - fontWeight: "bold", - }, - infoRow: { - // display: "flex", - // alignItems: "center", - // gap: theme.spacing(2), - }, - card: { - // padding: "20px", - margin: `${theme.spacing(3)}px 0px`, - borderRadius: 8, - }, - title: { - fontWeight: "bold", - }, - selectField: { - width: "50%", - }, -})); - -export default PersonalPreferences; diff --git a/apps/goat/app/[lng]/(dashboard)/settings/settings/Profile.tsx b/apps/goat/app/[lng]/(dashboard)/settings/settings/Profile.tsx deleted file mode 100644 index 6340e97b..00000000 --- a/apps/goat/app/[lng]/(dashboard)/settings/settings/Profile.tsx +++ /dev/null @@ -1,108 +0,0 @@ -"use client"; - -import React from "react"; -import { Box } from "@mui/material"; -import { makeStyles } from "@/lib/theme"; -import { v4 } from "uuid"; -import { TextField, Grid, Button } from "@mui/material"; -import { useTheme } from "@/lib/theme"; - -interface tempProfileInfoType { - label: string; - value: string; - editable: boolean; -} - -const Profile = () => { - const { classes, cx } = useStyles(); - const theme = useTheme(); - - const informatoryData: tempProfileInfoType[] = [ - { - label: "First Name", - value: "User", - editable: true, - }, - { - label: "Last Name", - value: "Costumer", - editable: true, - }, - { - label: "Email", - value: "user@gmail.com", - editable: true, - }, - { - label: "Phone Number", - value: "User", - editable: true, - }, - { - label: "Country", - value: "Germany", - editable: true, - }, - { - label: "Timezone", - value: "(GMT-12:00) International Date Line West", - editable: true, - }, - { - label: "Participant in organizations", - value: "LocalMapping, GOAT, Map4Ci...", - editable: true, - }, - ]; - - return ( -
- - {informatoryData.map((infoData) => ( - - - - - - ))} - - - - - -
- ); -}; - -const useStyles = makeStyles({ name: { Profile } })((theme) => ({ - label: { - fontWeight: "bold", - }, - infoRow: { - display: "flex", - alignItems: "center", - gap: theme.spacing(5), - margin: `${theme.spacing(3)}px ${theme.spacing(3)}px`, - }, - input: { - width: "100%", - }, - grid: { - // gap: "20px" - }, - deleteButton: { - color: theme.colors.palette.light.main, - }, - button: { - display: "block", - width: "100%", - padding: "14px", - margin: `${theme.spacing(3)}px 0px` - } -})); - -export default Profile; diff --git a/apps/goat/app/[lng]/(dashboard)/settings/settings/layout.tsx b/apps/goat/app/[lng]/(dashboard)/settings/settings/layout.tsx deleted file mode 100644 index d258dea6..00000000 --- a/apps/goat/app/[lng]/(dashboard)/settings/settings/layout.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import React from "react"; -import { Tabs } from "@p4b/ui/components/Navigation/Tabs"; - -const tabsData = [ - { - child: "Profile", - name: "Profile", - }, - { - child: "PersonalPreferences", - name: "Personal Preferences", - }, -]; - -const Settings = () => { - const tabs = tabsData.map(({ child, name }) => { - const Component = React.lazy(() => import(`@/app/[lng]/(dashboard)/settings/settings/${child}`)); - - return { - child: , - name, - }; - }); - - return ; -}; - -export default Settings; diff --git a/apps/goat/public/assets/poi-icons/circle.svg b/apps/goat/public/assets/poi-icons/circle.svg deleted file mode 100644 index 468fadfd..00000000 --- a/apps/goat/public/assets/poi-icons/circle.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/apps/goat/public/assets/poi-icons/star.svg b/apps/goat/public/assets/poi-icons/star.svg deleted file mode 100644 index f9f260e7..00000000 --- a/apps/goat/public/assets/poi-icons/star.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 9871b181..18f66d66 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -7,7 +7,6 @@ RUN apk update WORKDIR /app RUN npm install -g turbo COPY . . -COPY .env.docker /app/apps/web/.env RUN turbo prune --scope=@p4b/web --docker # Add lockfile and package.json's of isolated subworkspace @@ -24,9 +23,18 @@ RUN pnpm install --frozen-lockfile # Build the project COPY --from=builder /app/out/full/ . + +ARG NEXT_PUBLIC_APP_URL=APP_NEXT_PUBLIC_APP_URL +ARG NEXT_PUBLIC_MAP_TOKEN=APP_NEXT_PUBLIC_MAP_TOKEN +ARG NEXT_PUBLIC_ACCOUNTS_API_URL=APP_NEXT_PUBLIC_ACCOUNTS_API_URL +ARG NEXT_PUBLIC_GEOAPI_URL=APP_NEXT_PUBLIC_GEOAPI_URL +ARG NEXT_PUBLIC_API_URL=APP_NEXT_PUBLIC_API_URL + RUN pnpm dlx turbo run build --filter=web FROM base AS runner +RUN apk add bash + WORKDIR /app # Don't run production as root @@ -45,4 +53,6 @@ COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/publ ENV HOSTNAME localhost +COPY ./apps/web/entrypoint.sh /app/apps/web/entrypoint.sh +ENTRYPOINT ["/app/apps/web/entrypoint.sh"] CMD node apps/web/server.js diff --git a/apps/web/components/dashboard/common/FoldersTreeView.tsx b/apps/web/components/dashboard/common/FoldersTreeView.tsx index 6357bf31..cb34db96 100644 --- a/apps/web/components/dashboard/common/FoldersTreeView.tsx +++ b/apps/web/components/dashboard/common/FoldersTreeView.tsx @@ -129,7 +129,7 @@ export default function FoldersTreeView(props: FoldersTreeViewProps) { setEditModal(undefined); }} - existingFolderNames={folders?.items?.map((folder) => folder.name)} + existingFolderNames={folders?.map((folder) => folder.name)} selectedFolder={editModal?.selectedFolder} /> @@ -138,7 +138,7 @@ export default function FoldersTreeView(props: FoldersTreeViewProps) { component="nav" aria-labelledby="content-tree-view" > - {[folders?.items ?? [], teams ?? [], organizations ?? []].map( + {[folders ?? [], teams ?? [], organizations ?? []].map( (folder, typeIndex) => (
= ({ const [activeStep, setActiveStep] = useState(0); const [fileValue, setFileValue] = useState(); const [fileUploadError, setFileUploadError] = useState(); - const [selectedFolder, setSelectedFolder] = useState( - homeFolder, - ); + const [selectedFolder, setSelectedFolder] = useState(); const [datasetType, setDatasetType] = useState<"feature_layer" | "table">( "feature_layer", ); @@ -226,9 +224,7 @@ const DatasetUploadModal: React.FC = ({ }} autoHighlight id="folder-select" - options={ - folders?.items ? [homeFolder, ...folders.items] : [homeFolder] - } + options={folders ? [homeFolder, ...folders] : [homeFolder]} getOptionLabel={(option) => { if (typeof option === "string") { return option; diff --git a/apps/web/components/modals/Project.tsx b/apps/web/components/modals/Project.tsx index ec120c0a..f9181376 100644 --- a/apps/web/components/modals/Project.tsx +++ b/apps/web/components/modals/Project.tsx @@ -99,7 +99,7 @@ const ProjectModal: React.FC = ({ }; const folderOptions = useMemo(() => { - return folders?.items.map((folder) => { + return folders?.map((folder) => { return { value: folder.id, label: folder.name, diff --git a/apps/web/entrypoint.sh b/apps/web/entrypoint.sh new file mode 100755 index 00000000..d73d9198 --- /dev/null +++ b/apps/web/entrypoint.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# The first part wrapped in a function +makeSedCommands() { + printenv | \ + grep '^NEXT_PUBLIC' | \ + sed -r "s/=/ /g" | \ + xargs -n 2 bash -c 'echo "sed -i \"s#APP_$0#$1#g\""' +} + +# Set the delimiter to newlines (needed for looping over the function output) +IFS=$'\n' +# For each sed command +for c in $(makeSedCommands); do + # For each file in the .next directory + for f in $(find /app/apps/web/.next -type f); do + # Execute the command against the file + COMMAND="$c '$f'" + echo "Running: $COMMAND" + eval $COMMAND + done +done + +echo "Starting Nextjs" +# Run any arguments passed to this script +exec "$@" \ No newline at end of file diff --git a/apps/web/lib/api/folders.ts b/apps/web/lib/api/folders.ts index 9471def9..e35aa7e5 100644 --- a/apps/web/lib/api/folders.ts +++ b/apps/web/lib/api/folders.ts @@ -1,7 +1,7 @@ import useSWR from "swr"; import { fetchWithAuth, fetcher } from "@/lib/api/fetcher"; import type { GetContentQueryParams } from "@/lib/validations/common"; -import type { FolderPaginated } from "@/lib/validations/folder"; +import type { FolderResponse } from "@/lib/validations/folder"; export const FOLDERS_API_BASE_URL = new URL( "api/v2/folder", @@ -10,7 +10,7 @@ export const FOLDERS_API_BASE_URL = new URL( export const useFolders = (queryParams?: GetContentQueryParams) => { const { data, isLoading, error, mutate, isValidating } = - useSWR([`${FOLDERS_API_BASE_URL}`, queryParams], fetcher); + useSWR([`${FOLDERS_API_BASE_URL}`, queryParams], fetcher); return { folders: data, isLoading: isLoading, diff --git a/apps/web/lib/validations/folder.ts b/apps/web/lib/validations/folder.ts index 0ed72347..5938f8aa 100644 --- a/apps/web/lib/validations/folder.ts +++ b/apps/web/lib/validations/folder.ts @@ -1,5 +1,4 @@ import * as z from "zod"; -import { responseSchema } from "@/lib/validations/response"; export const folderSchema = z.object({ name: z.string(), @@ -7,9 +6,9 @@ export const folderSchema = z.object({ user_id: z.string().uuid() }); +export const folderResponse = z.array(folderSchema); -export const folderResponseSchema = responseSchema(folderSchema); export type Folder = z.infer; -export type FolderPaginated = z.infer; +export type FolderResponse = z.infer; diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..250078a8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3.3" + +services: + goat: + restart: always + build: + context: . + dockerfile: ./apps/web/Dockerfile + ports: + - 3000:3000 + env_file: + - .env diff --git a/package.json b/package.json index ae2df427..575fc6dc 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "dev": "turbo run dev --parallel", "start": "turbo run start --parallel", "generate": "turbo run generate", - "prepare": "cd ../../ && husky install ./app/client/.husky", + "prepare": "husky install ./.husky", "web": "dotenv -- turbo run dev --filter=web", "storybook": "turbo run dev --filter=storybook", "build-storybook": "turbo run build --filter=storybook",