Creating multi-arch building container and consolidated version to Dockerfiles.

pull/17/head
Jeromy Streets 6 years ago
parent b1b00805c3
commit ae0e44e9cc
  1. 1
      .dockerignore
  2. 12
      Dockerfile
  3. 23
      Dockerfile.all
  4. 21
      cli/version/version.go

@ -1,5 +1,6 @@
.git .git
.gitignore .gitignore
Dockerfile Dockerfile
Dockerfile.all
LICENSE LICENSE
README.md README.md

@ -1,7 +1,7 @@
FROM golang:1.11.3 as builder FROM golang:1.11.3 as builder
EXPOSE 8080 EXPOSE 8080
ENV VERSION 1.5.1
ENV BUILD_DIR /build ENV BUILD_DIR /build
RUN mkdir -p ${BUILD_DIR} RUN mkdir -p ${BUILD_DIR}
@ -12,9 +12,17 @@ RUN go mod download
COPY . . COPY . .
RUN go test -cover ./... 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 FROM scratch
COPY --from=builder /serve / COPY --from=builder /serve /
ENTRYPOINT ["/serve"] ENTRYPOINT ["/serve"]
CMD [] 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"

@ -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"

@ -7,27 +7,16 @@ import (
// Run print operation. // Run print operation.
func Run() error { func Run() error {
fmt.Printf("%s\n%s\n", Text, GoVersionText) fmt.Printf("%s\n%s\n", VersionText, GoVersionText)
return nil return nil
} }
var ( var (
// MajorVersion of static-file-server. // version is the application version set during build.
MajorVersion = 1 version string
// MinorVersion of static-file-server. // VersionText for directly accessing the static-file-server version.
MinorVersion = 5 VersionText = fmt.Sprintf("v%s", version)
// 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,
)
// GoVersionText for directly accessing the version of the Go runtime // GoVersionText for directly accessing the version of the Go runtime
// compiled with the static-file-server. // compiled with the static-file-server.

Loading…
Cancel
Save