diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..88cea06 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:21 AS build + +WORKDIR /app + +COPY package.json ./ +COPY package-lock.json ./ +RUN npm install +COPY . ./ +RUN npm run build + +RUN npm install --global http-server + +EXPOSE 8000 + +CMD ["npm", "run", "preview", "--", "--host", "--port", "8000"] \ No newline at end of file diff --git a/Makefile b/Makefile index c57902b..cd986a3 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,6 @@ run: npm run dev -- --host +docker_build: + docker build -t registry.computernetthings.ru/recipes/front . && docker image prune -f +docker_push: + docker push registry.computernetthings.ru/recipes/front diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index f10bad2..ec33284 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -5,15 +5,15 @@ import LoadingScreen from "/src/lib/LoadingScreen.svelte"; import ErrorLoading from '/src/lib/ErrorLoading.svelte'; - let serverurl = 'http://192.168.0.105:3000'; + let serverurl = 'https://recipesapi.computernetthings.ru'; let last_page = 1; let recipes_list = []; let last_recipe; // First loading - let recipes_p = axios.get(serverurl+"/recipes?page=" + last_page); + let recipes_p = axios.post(serverurl+"/recipes_page", {page: last_page}); recipes_p.then(function (response) { - axios.get(serverurl+"/recipe?r_id="+response.data.recipes[0].id).then(function (response) { + axios.post(serverurl+"/recipe", {recipe_id:response.data.recipes[0].id}).then(function (response) { last_recipe = response.data.recipe; console.log(last_recipe); }) @@ -27,7 +27,7 @@ // Inf loading function infiniteHandler({ detail: { loaded, complete } }) { last_page += 1; - axios.get(serverurl+"/recipes?page=" + last_page).then( + axios.post(serverurl+"/recipes_page", {page:last_page}).then( function (response) { if (response.data.recipes.length > 0) { recipes_list = [...recipes_list, ...response.data.recipes]; @@ -55,7 +55,7 @@

{last_recipe.desc}

- {last_recipe.title} + {last_recipe.title}
{/if} @@ -64,7 +64,7 @@ {#each recipes_list as recipe}
- {recipe.title} + {recipe.title}

{recipe.ctime} / {recipe.cal}

{recipe.title}

diff --git a/src/routes/Header.svelte b/src/routes/Header.svelte index c0c2bdd..e690725 100644 --- a/src/routes/Header.svelte +++ b/src/routes/Header.svelte @@ -25,7 +25,7 @@
@@ -63,7 +63,6 @@ -
- {data.data.recipe.title} + {data.data.recipe.title}
@@ -71,9 +71,9 @@ {#each data.data.recipe.ingredients as ingredients}
-
{ingredients.Title}
+
{ingredients.title}