Skip to content

Commit f27802f

Browse files
committed
update docker
1 parent 0e9514a commit f27802f

File tree

10 files changed

+71
-32
lines changed

10 files changed

+71
-32
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
ENV_VARIABLE=production_server_only_variable
55
NEXT_PUBLIC_ENV_VARIABLE=production_public_variable
6-
DB_LOCAL_URL=mongodb://mongo:27017/denizpaz
6+
NEXT_PUBLIC_DB_LOCAL_URL=mongodb://mongo:27017/denizpaz
77
PORT=3000
88
STORE_PATH=upload

.env.development

Lines changed: 0 additions & 7 deletions
This file was deleted.

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# DO NOT ADD SECRETS TO THIS FILE. This is a good place for defaults.
2+
# If you want to add secrets use `.env.local` instead.
3+
4+
ENV_VARIABLE=production_server_only_variable
5+
NEXT_PUBLIC_ENV_VARIABLE=production_public_variable
6+
NEXT_PUBLIC_DB_LOCAL_URL=mongodb://mongo:27017/denizpaz
7+
PORT=3000
8+
STORE_PATH=upload
9+
NEXT_PUBLIC_DB_LOCAL_URL=mongodb://mongo:27017/denizpaz

.env.local.example

Lines changed: 0 additions & 5 deletions
This file was deleted.

.env.production

Lines changed: 0 additions & 8 deletions
This file was deleted.

app/recipes/page.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,17 @@ import React from "react";
22
import LatestRecipes from "../../components/LatestRecipes";
33
import SingleRecipeTopSection from "../../components/SingleRecipeTopSection";
44

5-
// کامپوننت Recipes که لیست رسپی‌ها را نمایش می‌دهد
65
const Recipes = () => {
76
return (
87
<>
9-
{/* بخش بالایی */}
108
<SingleRecipeTopSection
119
sectionBackground={"/header-recipe.png"}
1210
recipeName="... رسپی ها ..."
1311
recipeDesc="دنبال یه دسر خاص و خوشمزه ای ؟ سریع پیداش کن ..."
1412
/>
15-
{/* بخش لیست رسپی‌ها */}
1613
<section id="recipes">
1714
<div className="container py-10">
1815
<div className="recipes-section">
19-
{/* استفاده از کامپوننت LatestRecipes برای نمایش لیست آخرین رسپی‌ها */}
2016
<LatestRecipes limitNumber={20} />
2117
</div>
2218
</div>

docker-compose.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ services:
99
NEXT_PUBLIC_ENV_VARIABLE: ${NEXT_PUBLIC_ENV_VARIABLE}
1010
restart: always
1111
volumes:
12+
- ./:/app/
1213
- /app/node_modules
1314
- /app/.next
1415
ports:
@@ -18,21 +19,29 @@ services:
1819
depends_on:
1920
- mongo
2021
networks:
21-
- asgard
22+
- MONGO
2223

2324
mongo:
2425
container_name: mongo
2526
image: mongo:latest
2627
volumes:
27-
- data:/data/db
28+
- type: volume
29+
source: MONGO_DATA
30+
target: /data/db
31+
- type: volume
32+
source: MONGO_CONFIG
33+
target: /data/configdb
2834
ports:
2935
- "27017:27017"
3036
networks:
31-
- asgard
37+
- MONGO
3238

3339
networks:
34-
asgard:
35-
# external: true
40+
MONGO:
41+
name: MONGO
3642

3743
volumes:
38-
data:
44+
MONGO_DATA:
45+
name: MONGO_DATA
46+
MONGO_CONFIG:
47+
name: MONGO_CONFIG

docs/recipes.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
کد فوق یک کامپوننت React به نام "Recipes" را تعریف می‌کند. این کامپوننت دو کامپوننت دیگر به نام‌های "LatestRecipes" و "SingleRecipeTopSection" را درون خود استفاده می‌کند. در ادامه، ماژول‌های موردنیاز برای React را وارد می‌کنیم.
3+
4+
```javascript
5+
import React from "react";
6+
import LatestRecipes from "../../components/LatestRecipes";
7+
import SingleRecipeTopSection from "../../components/SingleRecipeTopSection";
8+
```
9+
10+
سپس، تابع `Recipes` تعریف می‌شود. این تابع عملکرد صفحه "Recipes" را تعیین می‌کند. تابع برگشتی JSX است که اجزای مختلف صفحه را شامل می‌شود.
11+
12+
```javascript
13+
const Recipes = () => {
14+
return (
15+
<>
16+
<SingleRecipeTopSection
17+
sectionBackground={"/header-recipe.png"}
18+
recipeName="... رسپی ها ..."
19+
recipeDesc="دنبال یه دسر خاص و خوشمزه ای ؟ سریع پیداش کن ..."
20+
/>
21+
22+
<section id="recipes">
23+
<div className="container py-10">
24+
<div className="recipes-section">
25+
<LatestRecipes limitNumber={20} />
26+
</div>
27+
</div>
28+
</section>
29+
</>
30+
);
31+
};
32+
```
33+
34+
در این قسمت، ابتدا کامپوننت "SingleRecipeTopSection" را با استفاده از مقادیر ویژگی‌ها (props) فراخوانی می‌کنیم. این کامپوننت یک بخش بالایی برای نمایش یک رسپی خاص را ایجاد می‌کند. در این مثال، مقادیر ویژگی‌ها برای تنظیم تصویر پس زمینه بخش، نام رسپی و توضیحات رسپی استفاده می‌شود.
35+
36+
سپس، یک المان `<section>` با شناسه "recipes" تعریف می‌کنیم که درون آن یک المان `<div>` قرار دارد. این المان `<div>` حاوی یک کلاس "container py-10" است و درون آن یک المان `<div>` دیگر به عنوان "recipes-section" قرار دارد. درون این المان `<div>`، کامپوننت "LatestRecipes" قرار دارد که با استفاده از ویژگی (props) "limitNumber" تعداد محدودی از رسپی‌ها را نمایش می‌دهد.
37+
38+
در نهایت، کامپوننت "Recipes" را به عنوان کامپوننت پیش‌فرض (default) برای صادرات تعریف می‌کنیم.
39+
40+
```javascript
41+
export default Recipes;
42+
```
43+
44+
به این ترتیب، کد فوق یک صفحه "Recipes" را تعریف می‌کند که شامل بخش بالایی رسپی‌ها و لیستی از رسپی‌های جدید است.

environment.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ declare namespace NodeJS {
22
export interface ProcessEnv {
33
readonly ENV_VARIABLE: string
44
readonly NEXT_PUBLIC_ENV_VARIABLE: string
5+
readonly NEXT_PUBLIC_DB_LOCAL_URL: string
56

67
readonly DEVELOPMENT_ENV_VARIABLE: string
78
readonly NEXT_PUBLIC_DEVELOPMENT_ENV_VARIABLE: string

lib/mongodb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const options: any = {
1010
export const connectToDatabase = async () => {
1111
if (!connection.readyState) {
1212
// console.log('Connecting to ', DATABASE)
13-
await mongoose.connect(DATABASE || "mongodb://mongo:27017/denizpaz", options)
13+
await mongoose.connect(process.env.NEXT_PUBLIC_DB_LOCAL_URL, options)
1414
.then((c) => {
1515
console.log("Mongo Connected: ")
1616
})

0 commit comments

Comments
 (0)