diff --git a/Dockerfile b/Dockerfile index 58881de93..ac481c72e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,47 +2,72 @@ # Generic purpose Perkeep image, that builds the server (perkeepd) # and the command-line clients (pk, pk-put, pk-get, and pk-mount). -# Use misc/docker/go to generate perkeep/go -FROM perkeep/go +# TODO: add the HEIC-supporting imagemagick to this Dockerfile too, in +# some way that's minimally gross and not duplicating +# misc/docker/heiftojpeg's Dockerfile entirely. Not decided best way. +# TODO: likewise, djpeg binary? maybe. https://perkeep.org/issue/1142 -MAINTAINER camlistore +FROM buildpack-deps:stretch-scm AS pkbuild + +MAINTAINER Perkeep Authors ENV DEBIAN_FRONTEND noninteractive -RUN apt-get -y --no-install-recommends install adduser -RUN adduser --disabled-password --quiet --gecos Camli camli -RUN mkdir -p /gopath/bin -RUN chown camli.camli /gopath/bin -RUN mkdir -p /gopath/pkg -RUN chown camli.camli /gopath/pkg +# gcc for cgo, sqlite +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + gcc \ + libc6-dev \ + make \ + pkg-config \ + libsqlite3-dev -RUN mkdir -p /gopath/src -ADD internal /gopath/src/perkeep.org/internal -ADD app /gopath/src/perkeep.org/app -ADD dev /gopath/src/perkeep.org/dev -ADD cmd /gopath/src/perkeep.org/cmd -ADD vendor /gopath/src/perkeep.org/vendor -ADD server /gopath/src/perkeep.org/server -ADD pkg /gopath/src/perkeep.org/pkg -RUN mkdir -p /gopath/src/perkeep.org/clients -ADD clients/web /gopath/src/perkeep.org/clients/web -ADD make.go /gopath/src/perkeep.org/make.go -RUN echo 'dev' > /gopath/src/perkeep.org/VERSION +ENV GOLANG_VERSION 1.10.2 + +WORKDIR /usr/local +RUN wget -O go.tgz https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz +RUN echo "4b677d698c65370afa33757b6954ade60347aaca310ea92a63ed717d7cb0c2ff go.tgz" | sha256sum -c - +RUN tar -zxvf go.tgz ENV GOROOT /usr/local/go -ENV PATH $GOROOT/bin:/gopath/bin:$PATH -ENV GOPATH /gopath -ENV CGO_ENABLED 0 -ENV CAMLI_GOPHERJS_GOROOT /usr/local/go +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH -WORKDIR /gopath/src/perkeep.org -RUN go run make.go -RUN cp -a /gopath/src/perkeep.org/bin/* /gopath/bin/ +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" +WORKDIR $GOPATH -ENV USER camli -ENV HOME /home/camli -WORKDIR /home/camli +# Add each directory separately, so our context doesn't include the +# Dockerfile itself, to permit quicker iteration with docker's +# caching. +ADD app /go/src/perkeep.org/app +ADD clients /go/src/perkeep.org/clients +ADD cmd /go/src/perkeep.org/cmd +ADD config /go/src/perkeep.org/config +ADD dev /go/src/perkeep.org/dev +ADD doc /go/src/perkeep.org/doc +ADD internal /go/src/perkeep.org/internal +ADD pkg /go/src/perkeep.org/pkg +ADD server /go/src/perkeep.org/server +ADD vendor /go/src/perkeep.org/vendor +ADD website /go/src/perkeep.org/website +ADD make.go /go/src/perkeep.org/make.go + +WORKDIR /go/src/perkeep.org +RUN echo "0.10" > VERSION +RUN go run make.go --sqlite=true -v + + + +FROM debian:stretch + +RUN mkdir -p /home/keepy/bin +ENV HOME /home/keepy +ENV PATH /home/keepy/bin:$PATH + +COPY --from=pkbuild /go/bin/pk* /home/keepy/bin/ +COPY --from=pkbuild /go/bin/perkeepd /home/keepy/bin/ EXPOSE 80 443 3179 8080 +WORKDIR /home/keepy CMD /bin/bash diff --git a/Makefile b/Makefile index 82b0c9839..eeb4c6f2a 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +1,16 @@ # The normal way to build Perkeep is just "go run make.go", which -# works everywhere, even on systems without Make. The rest of this -# Makefile is mostly historical and should hopefully disappear over -# time. +# doesn't require make. This file is mostly little convenient aliases +# and notes. + all: go run make.go -# On OS X with "brew install sqlite3", you need PKG_CONFIG_PATH=/usr/local/Cellar/sqlite/3.7.17/lib/pkgconfig/ -full: - go install --ldflags="-X perkeep.org/pkg/buildinfo.GitInfo "`./misc/gitversion` `pkg-config --libs sqlite3 1>/dev/null 2>/dev/null && echo "--tags=with_sqlite"` ./pkg/... ./server/... ./cmd/... ./dev/... - - -# Workaround Go bug where the $GOPATH/pkg cache doesn't know about tag changes. -# Useful when you accidentally run "make" and then "make presubmit" doesn't work. -# See https://code.google.com/p/go/issues/detail?id=4443 -forcefull: - go install -a --tags=with_sqlite ./pkg/... ./server/perkeepd ./cmd/... ./dev/... - -oldpresubmit: fmt - SKIP_DEP_TESTS=1 go test `pkg-config --libs sqlite3 1>/dev/null 2>/dev/null && echo "--tags=with_sqlite"` -short ./pkg/... ./server/perkeepd/... ./cmd/... ./dev/... && echo PASS - presubmit: fmt - go run dev/devcam/*.go test -short - -embeds: - go install ./pkg/fileembed/genfileembed/ && genfileembed ./server/perkeepd/ui && genfileembed ./pkg/server - -UIDIR = server/perkeepd/ui - -NEWUIDIR = server/perkeepd/newui - -clean: - rm -f $(NEWUIDIR)/all.js $(NEWUIDIR)/all.js.map + go install perkeep.org/dev/devcam + devcam test -short fmt: - go fmt perkeep.org/cmd... perkeep.org/dev... perkeep.org/misc... perkeep.org/pkg... perkeep.org/server... + go fmt perkeep.org/cmd/... perkeep.org/dev/... perkeep.org/misc/... perkeep.org/pkg/... perkeep.org/server/... perkeep.org/internal/... + +dockerbuild: + docker build --tag=gcr.io/perkeep-containers/perkeep:latest .