mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-21 16:11:56 +00:00
Update scripts for new location
This commit is contained in:
parent
d268d939eb
commit
ef66e1c8df
@ -22,4 +22,6 @@ MAIL_FROM_NAME=
|
||||
|
||||
DEV_MODE=false
|
||||
GOSCROBBLE_DOMAIN=""
|
||||
STATIC_DIR="web"
|
||||
|
||||
DATA_DIR="/var/www/goscrobble-data"
|
||||
FRONTEND_DIRECTORY="/var/www/goscrobble-web"
|
||||
|
@ -5,7 +5,7 @@ variables:
|
||||
VERSION: 0.1.001
|
||||
|
||||
build-go:
|
||||
image: golang:1.16.7
|
||||
image: golang:1.16
|
||||
stage: build
|
||||
only:
|
||||
- master
|
||||
|
@ -51,10 +51,14 @@ func main() {
|
||||
goscrobble.RefereshExpiry = time.Duration(i) * time.Second
|
||||
}
|
||||
|
||||
goscrobble.StaticDirectory = "web"
|
||||
staticDirectoryStr := os.Getenv("STATIC_DIR")
|
||||
if staticDirectoryStr != "" {
|
||||
goscrobble.StaticDirectory = staticDirectoryStr
|
||||
goscrobble.DataDirectory = os.Getenv("DATA_DIRECTORY")
|
||||
if goscrobble.DataDirectory == "" {
|
||||
panic("DATA_DIRECTORY required in .env")
|
||||
}
|
||||
|
||||
goscrobble.FrontendDirectory = os.Getenv("FRONTEND_DIRECTORY")
|
||||
if goscrobble.FrontendDirectory == "" {
|
||||
panic("FRONTEND_DIRECTORY required in .env")
|
||||
}
|
||||
|
||||
// Ignore reverse proxies
|
||||
|
@ -32,4 +32,7 @@ These are stored in `web/.env.production` and `web/.env.development`
|
||||
|
||||
DEV_MODE=false // true|false - Defaults false
|
||||
GOSCROBBLE_DOMAIN="" // Full domain for email links (https://goscrobble.com))
|
||||
STATIC_DIR="web" // Location to store images (This will serve from web/static)
|
||||
|
||||
DATA_DIRECTORY="/var/www/goscrobble-data"
|
||||
FRONTEND_DIRECTORY="/var/www/goscrobble-web"
|
||||
|
||||
|
@ -2,12 +2,13 @@
|
||||
# Easy deploy script..
|
||||
|
||||
echo 'Fetching latest git commit'
|
||||
cd /var/www/goscrobble-api
|
||||
git pull
|
||||
|
||||
echo 'Building backend'
|
||||
go build -o goscrobble cmd/go-scrobble/*.go
|
||||
|
||||
cd web
|
||||
cd /var/www/goscrobble-web
|
||||
echo 'Installing frontend packages'
|
||||
npm install --production
|
||||
|
||||
|
@ -5,7 +5,7 @@ After=network.target
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
ExecStart=/bin/bash -c 'cd /root/go-scrobble && ./goscrobble'
|
||||
ExecStart=/bin/bash -c 'cd /var/www/goscrobble-api && ./goscrobble'
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
|
@ -8,13 +8,8 @@ import (
|
||||
)
|
||||
|
||||
func importImage(uuid string, url string) error {
|
||||
// Create the file
|
||||
path, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out, err := os.Create(path + string(os.PathSeparator) + StaticDirectory + string(os.PathSeparator) + "img" + string(os.PathSeparator) + uuid + "_full.jpg")
|
||||
// Create image
|
||||
out, err := os.Create(DataDirectory + string(os.PathSeparator) + "img" + string(os.PathSeparator) + uuid + "_full.jpg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -22,8 +22,9 @@ type jsonResponse struct {
|
||||
// List of Reverse proxies
|
||||
var ReverseProxies []string
|
||||
|
||||
// Static image directory
|
||||
var StaticDirectory string
|
||||
// Directories
|
||||
var FrontendDirectory string
|
||||
var DataDirectory string
|
||||
|
||||
// RequestRequest - Incoming JSON!
|
||||
type RequestRequest struct {
|
||||
@ -96,14 +97,14 @@ func HandleRequests(port string) {
|
||||
r.PathPrefix("/api")
|
||||
|
||||
// SERVE STATIC FILES - NO AUTH
|
||||
spaStatic := spaStaticHandler{staticPath: StaticDirectory}
|
||||
spaStatic := spaStaticHandler{staticPath: DataDirectory}
|
||||
r.PathPrefix("/img").Handler(spaStatic)
|
||||
|
||||
apiDocs := spaStaticHandler{staticPath: "docs/api/build"}
|
||||
r.PathPrefix("/docs").Handler(apiDocs)
|
||||
|
||||
// SERVE FRONTEND - NO AUTH
|
||||
spa := spaHandler{staticPath: "web/build", indexPath: "index.html"}
|
||||
spa := spaHandler{staticPath: FrontendDirectory + string(os.PathSeparator) + "build", indexPath: "index.html"}
|
||||
r.PathPrefix("/").Handler(spa)
|
||||
|
||||
c := cors.New(cors.Options{
|
||||
|
Loading…
Reference in New Issue
Block a user