update dockerfile, add dockerignore

master
Jeffrey Paul 4 yıl önce
ebeveyn e68027843d
işleme 488af3d373
  1. 1
      .dockerignore
  2. 2
      .gitignore
  3. 22
      Dockerfile
  4. 4
      Makefile
  5. 1
      go.mod
  6. 2
      go.sum
  7. 8
      process/formless.go

2
.gitignore sağlanmış

@ -1,3 +1,4 @@
formless
# ---> Go
# Binaries for programs and plugins
*.exe
@ -12,3 +13,4 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
.env

@ -1,5 +1,11 @@
## build image:
FROM golang:1.15 as builder
ARG GO_VERSION=1.15
FROM golang:${GO_VERSION}-alpine AS builder
RUN mkdir /user && \
echo 'nobody:x:65534:65534:nobody:/:' > /user/passwd && \
echo 'nobody:x:65534:' > /user/group
RUN apk add --no-cache ca-certificates git bzip2 make gcc libc-dev
RUN mkdir -p /go/src/git.eeqj.de/sneak/formless
WORKDIR /go/src/git.eeqj.de/sneak/formless
@ -8,14 +14,16 @@ COPY go.mod .
COPY go.sum .
RUN go mod download
ADD . /go/src/git.eeqj.de/sneak/formless/
COPY ./ ./
RUN make build
RUN tar -c /go | bzip2 > /go.tbz2
## output image:
FROM scratch
FROM scratch as final
COPY --from=builder /user/group /user/passwd /etc/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/src/git.eeqj.de/sneak/formless/formless /app/formless
COPY --from=builder /go /go.archive
COPY --from=builder /go.tbz2 /go.tbz2
WORKDIR /app
@ -24,4 +32,6 @@ ENV DBURL none
EXPOSE 8080
CMD ["./formless"]
USER nobody:nobody
ENTRYPOINT ["./formless"]

@ -77,4 +77,8 @@ upload-docker-image: docker
docker push $(IMAGENAME):$(BUILDTIMETAG)
docker push $(IMAGENAME):latest
vet:
go vet ./...
bash -c 'test -z "$$(gofmt -l .)"'
.PHONY: build fmt test is_uncommitted docker dist hub upload-docker-image clean run rundebug default build-docker-image-dist

@ -8,6 +8,7 @@ require (
github.com/gin-gonic/gin v1.6.3
github.com/google/uuid v1.1.2
github.com/jinzhu/gorm v1.9.16
github.com/joho/godotenv v1.3.0
github.com/k0kubun/pp v3.0.1+incompatible
github.com/labstack/echo v3.3.10+incompatible
github.com/labstack/gommon v0.3.0

@ -123,6 +123,8 @@ github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBef
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=

@ -5,6 +5,8 @@ import (
"os"
"time"
"github.com/joho/godotenv"
"git.eeqj.de/sneak/formless/database"
_ "github.com/jinzhu/gorm/dialects/postgres"
_ "github.com/jinzhu/gorm/dialects/sqlite"
@ -17,6 +19,12 @@ import (
// CLIEntry is the main entrypoint
func CLIEntry(version string, buildarch string) int {
err := godotenv.Load()
if err != nil {
panic("Error loading .env file")
}
f := new(Formless)
f.version = version
f.buildarch = buildarch

Yükleniyor…
İptal
Kaydet