Browse Source

Fix/docker (#1)

* Fix dockerfile
Vova Tkach 6 years ago
parent
commit
9a91d7ac53
2 changed files with 15 additions and 20 deletions
  1. 8 16
      Dockerfile
  2. 7 4
      Makefile

+ 8 - 16
Dockerfile

@@ -1,23 +1,15 @@
-FROM debian
+FROM debian:latest
 
 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 && \
+ADD https://github.com/vladimirok5959/golang-fave/releases/download/v1.0.0/fave.linux-amd64.tar.gz /app/fave.linux-amd64.tar.gz
+ADD https://github.com/vladimirok5959/golang-fave/releases/download/v1.0.0/localhost.tar.gz /app/hosts/localhost.tar.gz
+
+RUN tar -zxf /app/fave.linux-amd64.tar.gz -C /app && \
+ tar -zxf /app/hosts/localhost.tar.gz -C /app/hosts && \
  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 && \
+ rm /app/hosts/localhost.tar.gz && \
+ mkdir /app/src && cp -R /app/hosts/localhost /app/src && \
  chmod +x /app/fave.linux-amd64
 
 EXPOSE 8080

+ 7 - 4
Makefile

@@ -21,10 +21,13 @@ 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
+	@cp -R ./hosts/localhost ./bin/localhost
+	@-find ./bin/localhost -type f -name '.*' -exec rm -f {} \;
+	@-find ./bin/localhost -type f -name '*.json' -exec rm -f {} \;
+	@-rm ./bin/localhost/tmp/*
+	cd ./bin && tar -zcf localhost.tar.gz ./localhost
+	@-rm -r ./bin/localhost
+	cp ./Dockerfile ./bin/Dockerfile
 	cd ./bin && shasum -a 256 * > sha256sum.txt
 	cat ./bin/sha256sum.txt