update README.md + few fixes
This commit is contained in:
parent
07f096a0a5
commit
45bc90b940
21
README.md
21
README.md
@ -86,19 +86,24 @@ func (hm *HMMap) GetSwarmNetInfo() *HMNetInfo {
|
||||
* In your project root directory, create a `.homeserver` directory with a configuration file: `hmdeploy.json`:
|
||||
```json
|
||||
{
|
||||
"name": "<project-name>",
|
||||
"image": "<project-image-name>:<project-image-tag>",
|
||||
"name": "my-api",
|
||||
"dependencies": {
|
||||
"env": "<project-dot-env-path>",
|
||||
"compose": "<project-docker-compose-path>",
|
||||
"nginx": "<project-nginx-conf-path>"
|
||||
"swarm": {
|
||||
"env": ".env",
|
||||
"compose": "docker-compose.deploy.yml",
|
||||
"images": ["my-local-image:tag"]
|
||||
},
|
||||
"nginx": {
|
||||
"conf": "nginx.conf",
|
||||
"assets": "assets/"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
The filepaths can be absolute or relative. If the filename is only mentionned, it assumes the corresponding files are inside the `.homeserver` dir of your project.
|
||||
|
||||
The **image**, **env** and **nginx** fields are optionals.
|
||||
If you have a Docker registry with the target image available, you can thus leave image empty. It is used if you want to push a local image or don't have a docker registry.
|
||||
All **dependencies** fields are optionals. If you don't need swarm skip it, if you don't need .env skip it, if you don't nginx... You see the trick.
|
||||
If you have a Docker registry with the target image available, you can thus leave **images** field empty. It is used if you want to push a local image or don't have a docker registry.
|
||||
|
||||
## Run
|
||||
|
||||
@ -131,7 +136,7 @@ Usage of hmdeploy:
|
||||
-path string
|
||||
define the .homeserver project root dir (default ".")
|
||||
-version
|
||||
extract swarm details and return
|
||||
show program version and return
|
||||
|
||||
# if your are in the project dir with a `.homeserver`
|
||||
# you can then launch the program directly
|
||||
|
||||
@ -109,8 +109,8 @@ func (sd *SwarmDeployer) Build() error {
|
||||
log.Info().Msg("building swarm archive for deployment...")
|
||||
|
||||
filesToArchive := []string{}
|
||||
for idx := range sd.project.ImageNames {
|
||||
tarFile, err := sd.dloc.Save(sd.project.ImageNames[idx], sd.project.Dir)
|
||||
for idx := range sd.project.Deps.Swarm.ImageNames {
|
||||
tarFile, err := sd.dloc.Save(sd.project.Deps.Swarm.ImageNames[idx], sd.project.Dir)
|
||||
if err != nil {
|
||||
sd.setDone(err)
|
||||
return err
|
||||
@ -172,7 +172,7 @@ func (sd *SwarmDeployer) Deploy() error {
|
||||
|
||||
log.Info().Str("archive", sd.archivePath).Msg("deploying archive to swarm...")
|
||||
|
||||
if err := sd.drem.LoadImages(sd.project.ImageNames...); err != nil {
|
||||
if err := sd.drem.LoadImages(sd.project.Deps.Swarm.ImageNames...); err != nil {
|
||||
sd.setDone(err)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -3,7 +3,8 @@
|
||||
"dependencies": {
|
||||
"swarm": {
|
||||
"env": ".env",
|
||||
"compose": "docker-compose.deploy.yml"
|
||||
"compose": "docker-compose.deploy.yml",
|
||||
"images": []
|
||||
},
|
||||
"nginx": {
|
||||
"conf": "nginx.conf",
|
||||
|
||||
4
main.go
4
main.go
@ -418,7 +418,7 @@ func getSwarmServicesDetails(hm *models.HMMap) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() { //nolint: funlen //TODO: to reduce
|
||||
func main() { //nolint: funlen // TODO: to reduce
|
||||
ctx, fnCancel := signal.NotifyContext(
|
||||
context.Background(),
|
||||
os.Interrupt,
|
||||
@ -431,7 +431,7 @@ func main() { //nolint: funlen //TODO: to reduce
|
||||
noSwarm := flag.Bool("no-swarm", false, "no Swarm deployment")
|
||||
debug := flag.Bool("debug", false, "show debug logs")
|
||||
details := flag.Bool("details", false, "extract swarm details and return")
|
||||
version := flag.Bool("version", false, "extract swarm details and return")
|
||||
version := flag.Bool("version", false, "show program version and return")
|
||||
confirm := flag.Bool(
|
||||
"confirm",
|
||||
false,
|
||||
|
||||
@ -89,16 +89,16 @@ type Project struct {
|
||||
Name string `json:"name"`
|
||||
Dir string
|
||||
Deps struct {
|
||||
Swarm struct {
|
||||
EnvFile string `json:"env"`
|
||||
ComposeFile string `json:"compose"`
|
||||
} `json:"swarm"`
|
||||
Nginx struct {
|
||||
Conf string `json:"conf"`
|
||||
Assets string `json:"assets"`
|
||||
}
|
||||
Swarm struct {
|
||||
EnvFile string `json:"env"`
|
||||
ComposeFile string `json:"compose"`
|
||||
ImageNames []string `json:"images"`
|
||||
} `json:"swarm"`
|
||||
} `json:"dependencies"`
|
||||
ImageNames []string `json:"images"`
|
||||
}
|
||||
|
||||
func (p *Project) validate() error {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user