diff --git a/.dockerignore b/.dockerignore index 81cbee1..303dd4e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ .git .gitignore Dockerfile +Dockerfile.all LICENSE README.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 313be19..a1fb642 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM golang:1.11.3 as builder EXPOSE 8080 - +ENV VERSION 1.5.1 ENV BUILD_DIR /build RUN mkdir -p ${BUILD_DIR} @@ -12,9 +12,17 @@ RUN go mod download COPY . . RUN go test -cover ./... -RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o /serve /build/bin/serve +RUN CGO_ENABLED=0 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o /serve /build/bin/serve FROM scratch COPY --from=builder /serve / ENTRYPOINT ["/serve"] CMD [] + +# Metadata +LABEL life.apets.vendor="Halverneus" \ + life.apets.url="https://github.com/halverneus/static-file-server" \ + life.apets.name="Static File Server" \ + life.apets.description="A tiny static file server" \ + life.apets.version="v1.5.1" \ + life.apets.schema-version="1.0" diff --git a/Dockerfile.all b/Dockerfile.all new file mode 100644 index 0000000..1c870e3 --- /dev/null +++ b/Dockerfile.all @@ -0,0 +1,23 @@ +FROM golang:1.11.3 as builder + +EXPOSE 8080 +ENV VERSION 1.5.1 +ENV BUILD_DIR /build + +RUN mkdir -p ${BUILD_DIR} +WORKDIR ${BUILD_DIR} + +COPY . . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-amd64/serve /build/bin/serve +RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-arm6/serve /build/bin/serve +RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-arm7/serve /build/bin/serve +RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/linux-arm64/serve /build/bin/serve +RUN CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -a -tags netgo -installsuffix netgo -ldflags "-X github.com/halverneus/static-file-server/cli/version.version=${VERSION}" -o pkg/win-amd64/serve /build/bin/serve + +# Metadata +LABEL life.apets.vendor="Halverneus" \ + life.apets.url="https://github.com/halverneus/static-file-server" \ + life.apets.name="Static File Server" \ + life.apets.description="A tiny static file server" \ + life.apets.version="v1.5.1" \ + life.apets.schema-version="1.0" diff --git a/cli/version/version.go b/cli/version/version.go index d86d822..b1956c4 100644 --- a/cli/version/version.go +++ b/cli/version/version.go @@ -7,27 +7,16 @@ import ( // Run print operation. func Run() error { - fmt.Printf("%s\n%s\n", Text, GoVersionText) + fmt.Printf("%s\n%s\n", VersionText, GoVersionText) return nil } var ( - // MajorVersion of static-file-server. - MajorVersion = 1 + // version is the application version set during build. + version string - // MinorVersion of static-file-server. - MinorVersion = 5 - - // FixVersion of static-file-server. - FixVersion = 1 - - // Text for directly accessing the static-file-server version. - Text = fmt.Sprintf( - "v%d.%d.%d", - MajorVersion, - MinorVersion, - FixVersion, - ) + // VersionText for directly accessing the static-file-server version. + VersionText = fmt.Sprintf("v%s", version) // GoVersionText for directly accessing the version of the Go runtime // compiled with the static-file-server.