Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dfbe5da4be |
31
Dockerfile
31
Dockerfile
@@ -1,31 +0,0 @@
|
|||||||
FROM node:latest
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
golang-go
|
|
||||||
|
|
||||||
# Copy project directories
|
|
||||||
COPY frontend /app/frontend
|
|
||||||
COPY backend /app/backend
|
|
||||||
COPY yoomoney_src /app/yoomoney_src
|
|
||||||
WORKDIR /app/frontend/style
|
|
||||||
# Install Next.js and react-wavify
|
|
||||||
RUN npm install next --force && \
|
|
||||||
npm install react-wavify --force
|
|
||||||
# Start npm in background
|
|
||||||
CMD nohup npm run dev &
|
|
||||||
# Change to yoomoney_src directory and install Python dependencies
|
|
||||||
WORKDIR /app/yoomoney_src
|
|
||||||
RUN pip3 install -r requirements.txt --break-system-packages
|
|
||||||
# Run main.py in background
|
|
||||||
CMD nohup python3 main.py &
|
|
||||||
# Change to backend/api directory and run main.go
|
|
||||||
WORKDIR /app/backend/api
|
|
||||||
CMD nohup go run main.go &
|
|
||||||
|
|
||||||
# Change to backend/review directory and run main.go
|
|
||||||
WORKDIR /app/frontend/style/components
|
|
||||||
CMD nohup go run main.go &
|
|
||||||
EXPOSE 3000
|
|
||||||
CMD ["/bin/bash"]
|
|
||||||
BIN
backend/api/main
Executable file
BIN
backend/api/main
Executable file
Binary file not shown.
@@ -77,6 +77,7 @@ func initDB() {
|
|||||||
/*----------------------------PAYMENT--------------------------------------*/
|
/*----------------------------PAYMENT--------------------------------------*/
|
||||||
func payHandler(w http.ResponseWriter, r *http.Request) {
|
func payHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
fmt.Println("PAY HERE, BABY!")
|
||||||
// Структура для тела запроса на localhost:5000
|
// Структура для тела запроса на localhost:5000
|
||||||
type PaymentRequest struct {
|
type PaymentRequest struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
@@ -91,6 +92,11 @@ func payHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
cookie, err := r.Cookie("totalPrice")
|
cookie, err := r.Cookie("totalPrice")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("Не удалось получить amount из cookies")
|
||||||
|
fmt.Println("\nPrinting all cookies")
|
||||||
|
for _, c := range r.Cookies() {
|
||||||
|
fmt.Println(c)
|
||||||
|
}
|
||||||
http.Error(w, "Не удалось получить amount из cookies", http.StatusBadRequest)
|
http.Error(w, "Не удалось получить amount из cookies", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -98,6 +104,7 @@ func payHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Преобразуем amount из строки в float64
|
// Преобразуем amount из строки в float64
|
||||||
amount, err := strconv.ParseFloat(cookie.Value, 64)
|
amount, err := strconv.ParseFloat(cookie.Value, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("Некорректное значение amount в cookies")
|
||||||
http.Error(w, "Некорректное значение amount в cookies", http.StatusBadRequest)
|
http.Error(w, "Некорректное значение amount в cookies", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -113,6 +120,7 @@ func payHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Преобразуем тело запроса в JSON
|
// Преобразуем тело запроса в JSON
|
||||||
requestBody, err := json.Marshal(paymentRequest)
|
requestBody, err := json.Marshal(paymentRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("Ошибка при создании запроса")
|
||||||
http.Error(w, "Ошибка при создании запроса", http.StatusInternalServerError)
|
http.Error(w, "Ошибка при создании запроса", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -120,6 +128,7 @@ func payHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Отправляем POST-запрос на localhost:5000
|
// Отправляем POST-запрос на localhost:5000
|
||||||
resp, err := http.Post("http://localhost:5000/pay", "application/json", bytes.NewBuffer(requestBody))
|
resp, err := http.Post("http://localhost:5000/pay", "application/json", bytes.NewBuffer(requestBody))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Println("Ошибка при отправке запроса на сервер")
|
||||||
http.Error(w, "Ошибка при отправке запроса на сервер", http.StatusInternalServerError)
|
http.Error(w, "Ошибка при отправке запроса на сервер", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -128,6 +137,7 @@ func payHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Читаем ответ от сервера
|
// Читаем ответ от сервера
|
||||||
var paymentResponse PaymentResponse
|
var paymentResponse PaymentResponse
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&paymentResponse); err != nil {
|
if err := json.NewDecoder(resp.Body).Decode(&paymentResponse); err != nil {
|
||||||
|
fmt.Println("Ошибка при чтении ответа от сервера")
|
||||||
http.Error(w, "Ошибка при чтении ответа от сервера", http.StatusInternalServerError)
|
http.Error(w, "Ошибка при чтении ответа от сервера", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user