Browse Source

Dockerfile, script fixes, bootstrap upgrade

Vova Tkach 6 years ago
parent
commit
5e34f843f1
9 changed files with 48 additions and 5 deletions
  1. 26 0
      Dockerfile
  2. 14 0
      Makefile
  3. 1 1
      go.mod
  4. 2 0
      go.sum
  5. 1 1
      run.mac.sh
  6. 1 1
      run.unix.sh
  7. 1 1
      run.windows.bat
  8. 1 0
      vendor/github.com/vladimirok5959/golang-server-bootstrap/bootstrap/bootstrap.go
  9. 1 1
      vendor/modules.txt

+ 26 - 0
Dockerfile

@@ -0,0 +1,26 @@
+FROM debian
+
+ENV FAVE_HOST=0.0.0.0 FAVE_PORT=8080 FAVE_DIR=/app/hosts FAVE_DEBUG=false
+
+RUN apt-get update && \
+ apt-get install -y wget && \
+ mkdir /app && \
+ mkdir /app/hosts && \
+ mkdir /app/hosts/localhost && \
+ mkdir /app/hosts/localhost/config && \
+ mkdir /app/hosts/localhost/htdocs && \
+ mkdir /app/hosts/localhost/logs && \
+ mkdir /app/hosts/localhost/tmp && \
+ wget -O /app/fave.linux-amd64.tar.gz https://github.com/vladimirok5959/golang-fave/releases/download/v1.0.0/fave.linux-amd64.tar.gz && \
+ wget -O /app/hosts/localhost/template.tar.gz https://github.com/vladimirok5959/golang-fave/releases/download/v1.0.0/template.tar.gz && \
+ tar -zxf /app/fave.linux-amd64.tar.gz -C /app && \
+ tar -zxf /app/hosts/localhost/template.tar.gz -C /app/hosts/localhost && \
+ rm /app/fave.linux-amd64.tar.gz && \
+ rm /app/hosts/localhost/template.tar.gz && \
+ mkdir /app/src && cp -R /app/hosts/localhost/template /app/src && \
+ chmod +x /app/fave.linux-amd64
+
+EXPOSE 8080
+VOLUME /app/hosts
+
+CMD /app/fave.linux-amd64

+ 14 - 0
Makefile

@@ -21,6 +21,10 @@ build: clean
 	CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -mod vendor -a -o ./bin/fave.darwin-amd64 -ldflags='-X main.Version=$(VERSION) -extldflags "-static"'
 	CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -mod vendor -a -o ./bin/fave.windows-amd64.exe -ldflags='-X main.Version=$(VERSION) -extldflags "-static"'
 	cd ./bin && find . -name 'fave*' | xargs -I{} tar czf {}.tar.gz {}
+	@cp -R ./hosts/localhost/template ./bin/template
+	@-rm ./bin/template/.keep
+	cd ./bin && tar -zcf template.tar.gz ./template
+	@-rm -r ./bin/template
 	cd ./bin && shasum -a 256 * > sha256sum.txt
 	cat ./bin/sha256sum.txt
 
@@ -33,3 +37,13 @@ format:
 update:
 	go mod vendor
 	go mod download
+
+docker-test:
+	@-docker stop fave-test
+	@-docker rm fave-test
+	@-docker rmi fave
+	docker build -t fave .
+	docker run --name fave-test -d -p 8080:8080 -t -i fave:latest /app/fave.linux-amd64
+
+docker-build-pure:
+	docker build -t fave .

+ 1 - 1
go.mod

@@ -2,7 +2,7 @@ module golang-fave
 
 require (
 	github.com/go-sql-driver/mysql v1.4.1
-	github.com/vladimirok5959/golang-server-bootstrap v1.0.2
+	github.com/vladimirok5959/golang-server-bootstrap v1.0.3
 	github.com/vladimirok5959/golang-server-resources v1.0.2
 	github.com/vladimirok5959/golang-server-sessions v1.0.1
 	github.com/vladimirok5959/golang-server-static v1.0.0

+ 2 - 0
go.sum

@@ -3,6 +3,8 @@ github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
 github.com/vladimirok5959/golang-server-bootstrap v1.0.2 h1:UiOKkiNGcEddnx9O0cuLM1euSWgKimQCFIMD0+W8njw=
 github.com/vladimirok5959/golang-server-bootstrap v1.0.2/go.mod h1:R5PGBuqlupYd0evIXoi81plWH/HpNQO2V/jHxZzg2y0=
+github.com/vladimirok5959/golang-server-bootstrap v1.0.3 h1:fNLzc3qZrB1SiX7PtjPU+mel/TJFuy6nI2y/9Pup6Uw=
+github.com/vladimirok5959/golang-server-bootstrap v1.0.3/go.mod h1:R5PGBuqlupYd0evIXoi81plWH/HpNQO2V/jHxZzg2y0=
 github.com/vladimirok5959/golang-server-resources v1.0.2 h1:XwxFXyaOtfDGRmYp8P9q4P4gx4YK8NiYacpHe9V8Lck=
 github.com/vladimirok5959/golang-server-resources v1.0.2/go.mod h1:tsf2oAEf3E3ukiQSCO7dstl0IXbEXec68UUIiMWysBc=
 github.com/vladimirok5959/golang-server-sessions v1.0.1 h1:cQsLk8hz7pkIV7/XectfejDF2j+61FE+/s4xErxBNJw=

+ 1 - 1
run.mac.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-bin/fave.darwin-amd64 -host 0.0.0.0 -port 8080 -dir ./hosts -debug true
+bin/fave.darwin-amd64 -host 0.0.0.0 -port 8080 -dir ./hosts

+ 1 - 1
run.unix.sh

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-bin/fave.linux-amd64 -host 0.0.0.0 -port 8080 -dir ./hosts -debug true
+bin/fave.linux-amd64 -host 0.0.0.0 -port 8080 -dir ./hosts

+ 1 - 1
run.windows.bat

@@ -1,2 +1,2 @@
-bin/fave.windows-amd64.exe -host 0.0.0.0 -port 8080 -dir hosts -debug true
+bin/fave.windows-amd64.exe -host 0.0.0.0 -port 8080 -dir hosts
 TIMEOUT /T 5

+ 1 - 0
vendor/github.com/vladimirok5959/golang-server-bootstrap/bootstrap/bootstrap.go

@@ -76,6 +76,7 @@ func Start(h hndl, host string, timeout time.Duration, path string, before callb
 		if err := srv.ListenAndServe(); err != nil {
 			if err != http.ErrServerClosed {
 				fmt.Println(err)
+				stop <- os.Interrupt
 			}
 		}
 	}()

+ 1 - 1
vendor/modules.txt

@@ -1,6 +1,6 @@
 # github.com/go-sql-driver/mysql v1.4.1
 github.com/go-sql-driver/mysql
-# github.com/vladimirok5959/golang-server-bootstrap v1.0.2
+# github.com/vladimirok5959/golang-server-bootstrap v1.0.3
 github.com/vladimirok5959/golang-server-bootstrap/bootstrap
 # github.com/vladimirok5959/golang-server-resources v1.0.2
 github.com/vladimirok5959/golang-server-resources/resource