Skip to content
Snippets Groups Projects
Unverified Commit d07cdd92 authored by Bruno Michel's avatar Bruno Michel Committed by GitHub
Browse files

Fix self-hosted release with go modules (#1989)

parent 1c915b84
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,8 @@ adapt to your own system. ...@@ -33,7 +33,8 @@ adapt to your own system.
```bash ```bash
# From your cozy-stack developement folder # From your cozy-stack developement folder
docker run -it --rm --name cozy-stack \ docker run -it --rm --name cozy-stack \
-v $(pwd):/go/src/github.com/cozy/cozy-stack \ --workdir /app \
-v $(pwd):/app \
-v $(pwd):/go/bin \ -v $(pwd):/go/bin \
golang:1.12 \ golang:1.12 \
go get -v github.com/cozy/cozy-stack go get -v github.com/cozy/cozy-stack
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
# It should not be used for hosting your cozy cloud in production. # It should not be used for hosting your cozy cloud in production.
# Multi-stage image: this step builds cozy-stack # Multi-stage image: this step builds cozy-stack (and mailhog)
FROM golang:1.12 as build FROM golang:1.12 as build
WORKDIR /go/src/github.com/cozy/cozy-stack WORKDIR /app
# MailHog # MailHog
ENV MAILHOG_SRC_URL=https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64 \ ENV MAILHOG_SRC_URL=https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64 \
...@@ -14,9 +14,15 @@ RUN set -eu; curl -fsSL "$MAILHOG_SRC_URL" -o MailHog \ ...@@ -14,9 +14,15 @@ RUN set -eu; curl -fsSL "$MAILHOG_SRC_URL" -o MailHog \
&& echo "$MAILHOG_SRC_SHA256 MailHog" | sha256sum -c - \ && echo "$MAILHOG_SRC_SHA256 MailHog" | sha256sum -c - \
&& chmod +x MailHog && chmod +x MailHog
# Use docker layer caching to avoid redownloading go modules if the code has
# changed but not the dependencies.
COPY go.mod .
COPY go.sum .
RUN go mod download
# Build cozy-stack # Build cozy-stack
COPY . . COPY . .
RUN go get -d -v ./... && ./scripts/build.sh dev RUN ./scripts/build.sh dev
# Multi-stage image: the main image # Multi-stage image: the main image
...@@ -73,10 +79,10 @@ RUN set -eux; apt-get update \ ...@@ -73,10 +79,10 @@ RUN set -eux; apt-get update \
COPY --from=build \ COPY --from=build \
/go/src/github.com/cozy/cozy-stack/cozy-stack \ /app/cozy-stack \
/go/src/github.com/cozy/cozy-stack/scripts/docker-entrypoint.sh \ /app/scripts/docker-entrypoint.sh \
/go/src/github.com/cozy/cozy-stack/scripts/cozy-app-dev.sh \ /app/scripts/cozy-app-dev.sh \
/go/src/github.com/cozy/cozy-stack/MailHog \ /app/MailHog \
/usr/bin/ /usr/bin/
EXPOSE 8080 6060 8025 5984 EXPOSE 8080 6060 8025 5984
......
...@@ -95,8 +95,7 @@ do_build() { ...@@ -95,8 +95,7 @@ do_build() {
go build -ldflags "\ go build -ldflags "\
-X github.com/cozy/cozy-stack/pkg/config.Version=${VERSION_STRING} \ -X github.com/cozy/cozy-stack/pkg/config.Version=${VERSION_STRING} \
-X github.com/cozy/cozy-stack/pkg/config.BuildTime=${BUILD_TIME} \ -X github.com/cozy/cozy-stack/pkg/config.BuildTime=${BUILD_TIME} \
-X github.com/cozy/cozy-stack/pkg/config.BuildMode=${BUILD_MODE} -X github.com/cozy/cozy-stack/pkg/config.BuildMode=${BUILD_MODE}" \
" \
-o "${BINARY}" -o "${BINARY}"
popd > /dev/null popd > /dev/null
echo "ok" echo "ok"
......
...@@ -3,8 +3,6 @@ set -xe ...@@ -3,8 +3,6 @@ set -xe
RELEASE="$(git describe --tags)" RELEASE="$(git describe --tags)"
go get -u -v ./... || true # Always fail if you are in a tag…
docker build -t "cozy/cozy-app-dev:${RELEASE}" -f scripts/Dockerfile . docker build -t "cozy/cozy-app-dev:${RELEASE}" -f scripts/Dockerfile .
docker push "cozy/cozy-app-dev:${RELEASE}" docker push "cozy/cozy-app-dev:${RELEASE}"
docker tag "cozy/cozy-app-dev:${RELEASE}" "cozy/cozy-app-dev:latest" docker tag "cozy/cozy-app-dev:${RELEASE}" "cozy/cozy-app-dev:latest"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment