Docker version is automaticly differentiate itself from dev bersion
This commit is contained in:
parent
135546b3c8
commit
eb1471ef06
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,6 +15,7 @@ secret.env
|
||||
|
||||
privkey.pem
|
||||
fullchain.pem
|
||||
gin.log
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
|
||||
@ -15,6 +15,9 @@ services:
|
||||
- 127.0.0.1:9876:9876
|
||||
networks:
|
||||
- app-network
|
||||
environment:
|
||||
- ENV=docker
|
||||
- DOMAIN=localhost
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
|
||||
@ -2,6 +2,7 @@ FROM node:18-alpine as builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV VITE_ENV=docker
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
|
||||
@ -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: {
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user