Docker version is automaticly differentiate itself from dev bersion

This commit is contained in:
Max 2025-01-26 11:18:24 +03:00
parent 135546b3c8
commit eb1471ef06
6 changed files with 37 additions and 5 deletions

1
.gitignore vendored
View File

@ -15,6 +15,7 @@ secret.env
privkey.pem
fullchain.pem
gin.log
# Editor directories and files
.vscode/*

View File

@ -15,6 +15,9 @@ services:
- 127.0.0.1:9876:9876
networks:
- app-network
environment:
- ENV=docker
- DOMAIN=localhost
restart: unless-stopped
networks:

View File

@ -2,6 +2,7 @@ FROM node:18-alpine as builder
WORKDIR /app
ENV VITE_ENV=docker
COPY package*.json ./
RUN npm ci
COPY . .

View File

@ -1,8 +1,12 @@
import axios from "axios";
const environment = import.meta.env.VITE_ENV || 'development';
// const environment = "docker"
const baseURL = environment === "docker" ? "https://localhost/api/v1/" : "http://localhost:9876/";
export const axiosLocalhost = axios.create(
{
baseURL: `https://localhost/api/v1/`,
baseURL: baseURL,
withCredentials: true,
headers: {

View File

@ -1,9 +1,32 @@
package global
const PathForCookies = "/"
const DomainForCookies = "127.0.0.1"
import (
"fmt"
"os"
)
var PathForCookies = "/"
var DomainForCookies = "127.0.0.1"
const SecureForCookies = false
const HttpOnlyForCookies = false
// Change to 0.0.0.0 when docker this
const GinWorkPath = "127.0.0.1:9876"
func GetGinWorkPath() string {
if os.Getenv("DOMAIN") != "" {
DomainForCookies = os.Getenv("DOMAIN")
PathForCookies = "/api/v1/"
fmt.Println("DomainForCookies is", DomainForCookies)
}
if os.Getenv("ENV") == "docker" {
fmt.Println("GinWorkPath is docker 0.0.0.0:9876")
return "0.0.0.0:9876"
}
fmt.Println("GinWorkPath is local 127.0.0.1:9876")
return GinWorkPath
}

View File

@ -43,7 +43,7 @@ func main() {
return
}
// Transaction
// Test Transaction
tx, _ := db_connection.Dbx.Begin(context.Background())
defer tx.Rollback(context.Background())
@ -59,7 +59,7 @@ func main() {
return
}
router.Run(global.GinWorkPath)
router.Run(global.GetGinWorkPath())
fmt.Printf("Hey!, %v", "you")
}