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
|
privkey.pem
|
||||||
fullchain.pem
|
fullchain.pem
|
||||||
|
gin.log
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
|
|||||||
@ -15,6 +15,9 @@ services:
|
|||||||
- 127.0.0.1:9876:9876
|
- 127.0.0.1:9876:9876
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
|
environment:
|
||||||
|
- ENV=docker
|
||||||
|
- DOMAIN=localhost
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@ -2,6 +2,7 @@ FROM node:18-alpine as builder
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV VITE_ENV=docker
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
import axios from "axios";
|
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(
|
export const axiosLocalhost = axios.create(
|
||||||
{
|
{
|
||||||
baseURL: `https://localhost/api/v1/`,
|
baseURL: baseURL,
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
headers: {
|
headers: {
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,32 @@
|
|||||||
package global
|
package global
|
||||||
|
|
||||||
const PathForCookies = "/"
|
import (
|
||||||
const DomainForCookies = "127.0.0.1"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
var PathForCookies = "/"
|
||||||
|
var DomainForCookies = "127.0.0.1"
|
||||||
|
|
||||||
const SecureForCookies = false
|
const SecureForCookies = false
|
||||||
const HttpOnlyForCookies = false
|
const HttpOnlyForCookies = false
|
||||||
|
|
||||||
// Change to 0.0.0.0 when docker this
|
// Change to 0.0.0.0 when docker this
|
||||||
const GinWorkPath = "127.0.0.1:9876"
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transaction
|
// Test Transaction
|
||||||
tx, _ := db_connection.Dbx.Begin(context.Background())
|
tx, _ := db_connection.Dbx.Begin(context.Background())
|
||||||
defer tx.Rollback(context.Background())
|
defer tx.Rollback(context.Background())
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
router.Run(global.GinWorkPath)
|
router.Run(global.GetGinWorkPath())
|
||||||
|
|
||||||
fmt.Printf("Hey!, %v", "you")
|
fmt.Printf("Hey!, %v", "you")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user