Added a couple of Makefiles to simply build and deploy
parent
e78e7427ac
commit
81da287b96
@ -0,0 +1,12 @@
|
||||
|
||||
# Example ".env" for development, just copy this file to ".env" and edit that one
|
||||
MODE=development
|
||||
|
||||
# Development server host
|
||||
HOST=:4000
|
||||
|
||||
# Development server url
|
||||
URL=http://localhost:3000
|
||||
|
||||
EMAIL=mail@example.org
|
||||
|
@ -1,2 +1,3 @@
|
||||
node_modules/
|
||||
dist/
|
||||
.env
|
@ -0,0 +1,25 @@
|
||||
|
||||
.PHONY: all
|
||||
all: setup build
|
||||
|
||||
.PHONY: setup
|
||||
setup:
|
||||
cp -n .env.dev .env
|
||||
cp -n .env.dev server/.env
|
||||
mkdir -p dist/
|
||||
|
||||
$(MAKE) -C server setup
|
||||
$(MAKE) -C client setup
|
||||
|
||||
# rsync options: [a]rchive [c]hecksum [v]erbose [h]uman
|
||||
.PHONY: build
|
||||
build:
|
||||
$(MAKE) -C server build
|
||||
$(MAKE) -C client build
|
||||
|
||||
rsync -acvh server/bin/posti-dm dist/
|
||||
rsync -acvh client/dist/ dist/
|
||||
|
||||
cp .env dist/.env
|
||||
|
||||
|
@ -1,7 +1,53 @@
|
||||
# Posti DM
|
||||
|
||||
![homepage screenshot](./screenshot.png)
|
||||
|
||||
Prototipo di applicazione web per prenotare posti in dipartimento.
|
||||
|
||||
- FrontEnd: Vite + VanillaJS
|
||||
- FrontEnd: Vite + VanillaJS (?)
|
||||
|
||||
- BackEnd: Golang + go-chi + godotent + sqlite3 (?)
|
||||
|
||||
## Usage
|
||||
|
||||
The first time you want to build the project you should run first
|
||||
|
||||
```bash
|
||||
$ make setup
|
||||
```
|
||||
|
||||
Then to build the client and the server just run
|
||||
|
||||
```bash
|
||||
$ make build
|
||||
```
|
||||
|
||||
### Running: In Development
|
||||
|
||||
You need to start two concurrent processes as follows
|
||||
|
||||
```bash
|
||||
#
|
||||
# Firstly start the backend
|
||||
#
|
||||
$ cd server
|
||||
$ go run .
|
||||
|
||||
# or also to reload the server on changes with "entr"
|
||||
$ find -name '*.go' | entr -r -s 'go run .'
|
||||
|
||||
#
|
||||
# Then in another shell start ViteJS to live-reload the frontend
|
||||
#
|
||||
$ cd client
|
||||
$ npm run dev
|
||||
```
|
||||
|
||||
### Running: In Production
|
||||
|
||||
Just `make build` at the root of the project and then run the following (ehm forse alcuni path sono relativi rispetto alla directory corrent quindi per ora è meglio fare `cd` dentro `dist/`)
|
||||
|
||||
- BackEnd: Golang + go-chi + sqlite3 (?)
|
||||
```bash
|
||||
$ cd dist/
|
||||
$ ./posti-dm
|
||||
```
|
||||
|
@ -0,0 +1,12 @@
|
||||
|
||||
.PHONY: all
|
||||
all: setup build
|
||||
|
||||
.PHONY: setup
|
||||
setup:
|
||||
mkdir -p dist/
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
npm run build
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 133 KiB |
@ -0,0 +1,20 @@
|
||||
|
||||
.PHONY: all
|
||||
all: setup build
|
||||
|
||||
.PHONY: setup
|
||||
setup:
|
||||
mkdir -p bin/
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
go build -o bin/posti-dm .
|
||||
|
||||
.PHONY: run
|
||||
run:
|
||||
go run .
|
||||
|
||||
.PHONY: watch
|
||||
watch:
|
||||
find -name '*.go' | entr -r -s 'go run .'
|
||||
|
@ -0,0 +1,37 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
var Mode string
|
||||
|
||||
var Host string
|
||||
var Url string
|
||||
|
||||
var Email string
|
||||
|
||||
func loadEnv(target *string, name, defaultValue string) {
|
||||
value := os.Getenv(name)
|
||||
if len(strings.TrimSpace(value)) == 0 {
|
||||
*target = defaultValue
|
||||
} else {
|
||||
*target = value
|
||||
}
|
||||
log.Printf("%s = %v", name, *target)
|
||||
}
|
||||
|
||||
func Load() {
|
||||
godotenv.Load()
|
||||
|
||||
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
||||
|
||||
loadEnv(&Mode, "MODE", "production")
|
||||
loadEnv(&Host, "HOST", "localhost:4000")
|
||||
loadEnv(&Url, "URL", "http://localhost:3000")
|
||||
loadEnv(&Email, "EMAIL", "mail@example.org")
|
||||
}
|
Loading…
Reference in New Issue