mirror of
https://github.com/JuLi0n21/pwa-player.git
synced 2026-04-19 15:30:05 +00:00
updating dockerfiles and minor things
This commit is contained in:
0
data/.gitkeep
Normal file
0
data/.gitkeep
Normal file
BIN
data/database.db
Normal file
BIN
data/database.db
Normal file
Binary file not shown.
@@ -7,13 +7,13 @@ RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o main .
|
||||
|
||||
FROM gcr.io/distroless/base-debian11
|
||||
RUN CGO_ENABLED=1 GOOS=linux go build -o main .
|
||||
|
||||
FROM ubuntu:latest
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/main .
|
||||
COPY --from=builder /app/dev.env .
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ const (
|
||||
|
||||
func InitDB() {
|
||||
var err error
|
||||
db, err = sql.Open("sqlite3", "database.db")
|
||||
db, err = sql.Open("sqlite3", "data/database.db")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -2,16 +2,24 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
if ok := godotenv.Load("dev.env"); ok != nil {
|
||||
if value := os.Getenv("ENV"); value == "prod" {
|
||||
if ok := godotenv.Load(".env"); ok != nil {
|
||||
panic(".env not found")
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Not Produktion Enviorment fallback to dev.env")
|
||||
if ok := godotenv.Load("dev.env"); ok != nil {
|
||||
panic("dev.env not found")
|
||||
}
|
||||
|
||||
}
|
||||
InitDB()
|
||||
|
||||
err := run()
|
||||
|
||||
6
start.sh
6
start.sh
@@ -23,14 +23,14 @@ docker build -t "$BACKEND_IMAGE" "$REPO_DIR/proxy" # Assuming proxy is the backe
|
||||
echo "Building frontend Docker image..."
|
||||
docker build -t "$FRONTEND_IMAGE" "$REPO_DIR/frontend" # Assuming frontend is the frontend directory
|
||||
|
||||
if [ "$(docker ps -q -f name=$BACKEND_CONTAINER)" ]; then
|
||||
if [ "$(docker ps -aq -f name=$BACKEND_CONTAINER)" ]; then
|
||||
echo "Stopping old backend container..."
|
||||
docker stop "$BACKEND_CONTAINER"
|
||||
echo "Removing old backend container..."
|
||||
docker rm "$BACKEND_CONTAINER"
|
||||
fi
|
||||
|
||||
if [ "$(docker ps -q -f name=$FRONTEND_CONTAINER)" ]; then
|
||||
if [ "$(docker ps -aq -f name=$FRONTEND_CONTAINER)" ]; then
|
||||
echo "Stopping old frontend container..."
|
||||
docker stop "$FRONTEND_CONTAINER"
|
||||
echo "Removing old frontend container..."
|
||||
@@ -38,7 +38,7 @@ if [ "$(docker ps -q -f name=$FRONTEND_CONTAINER)" ]; then
|
||||
fi
|
||||
|
||||
echo "Running new backend container..."
|
||||
docker run -d -p "$BACKEND_PORT":80 --name "$BACKEND_CONTAINER" "$BACKEND_IMAGE"
|
||||
docker run -d -p "$BACKEND_PORT":80 --name "$BACKEND_CONTAINER" -v "$REPO_DIR/data:/app/data" "$BACKEND_IMAGE"
|
||||
|
||||
echo "Running new frontend container..."
|
||||
docker run -d -p "$FRONTEND_PORT":80 --name "$FRONTEND_CONTAINER" "$FRONTEND_IMAGE"
|
||||
|
||||
Reference in New Issue
Block a user