Skip to content

Commit

Permalink
removes .git from build layer, emulates GH build (#1375)
Browse files Browse the repository at this point in the history
* removes .git from build layer, emulates GH build #269

* rundev target with git version passed in
  • Loading branch information
umputun authored Jun 5, 2022
1 parent 6f81bf0 commit 6309443
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/.vscode/
/.idea/
/bin/
/.git/

# source files
docker-compose.yml
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM umputun/baseimage:buildgo-v1.8.0 as build-backend
FROM umputun/baseimage:buildgo-v1.9.1 as build-backend

ARG CI
ARG GITHUB_REF
Expand All @@ -8,7 +8,6 @@ ARG SKIP_BACKEND_TEST
ARG BACKEND_TEST_TIMEOUT

ADD backend /build/backend
ADD .git/ /build/backend/.git/
WORKDIR /build/backend

ENV GOFLAGS="-mod=vendor"
Expand Down Expand Up @@ -73,7 +72,7 @@ RUN if [ -z "$SKIP_FRONTEND_BUILD" ] ; then \
; fi
RUN rm -rf ./node_modules

FROM umputun/baseimage:app-v1.8.0
FROM umputun/baseimage:app-v1.9.1

WORKDIR /srv

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.artifacts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ RUN cd /srv/frontend && \
npm run build && \
rm -rf ./node_modules

FROM umputun/baseimage:buildgo-latest as build-backend
FROM umputun/baseimage:buildgo-v1.9.1 as build-backend

ARG GITHUB_TOKEN
ARG GITHUB_REF
ARG GITHUB_SHA
ENV SKIP_BACKEND_TEST=true

WORKDIR /build/backend
ADD backend /build/backend
ADD README.md /build/
ADD LICENSE /build/

ADD .git/ /build/backend/.git/

COPY --from=build-frontend /srv/frontend/public/ web

RUN \
Expand Down
21 changes: 14 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
OS=linux
ARCH=amd64
GITHUB_REF=$(shell git rev-parse --symbolic-full-name HEAD)
GITHUB_SHA=$(shell git rev-parse --short HEAD)

bin:
docker build -f Dockerfile.artifacts -t remark42.bin .
Expand All @@ -9,22 +11,26 @@ bin:
docker rm -f remark42.bin

docker:
docker build -t umputun/remark42 --build-arg SKIP_FRONTEND_TEST=true --build-arg SKIP_BACKEND_TEST=true .
docker build -t umputun/remark42 --build-arg GITHUB_REF=$(GITHUB_REF) --build-arg GITHUB_SHA=$(GITHUB_SHA) \
--build-arg CI=true --build-arg SKIP_FRONTEND_TEST=true --build-arg SKIP_BACKEND_TEST=true .

dockerx:
docker buildx build --build-arg SKIP_FRONTEND_TEST=true --build-arg SKIP_BACKEND_TEST=true \
--progress=plain --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/umputun/remark42:master -t umputun/remark42:master .
docker buildx build --build-arg GITHUB_REF=$(GITHUB_REF) --build-arg GITHUB_SHA=$(GITHUB_SHA) --build-arg CI=true \
--build-arg SKIP_FRONTEND_TEST=true --build-arg SKIP_BACKEND_TEST=true \
--progress=plain --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/umputun/remark42:master -t umputun/remark42:master .

release:
docker build -f Dockerfile.artifacts --no-cache --pull -t remark42.bin .
docker build -f Dockerfile.artifacts --no-cache --pull --build-arg CI=true \
--build-arg GITHUB_REF=$(GITHUB_REF) --build-arg GITHUB_SHA=$(GITHUB_SHA) -t remark42.bin .
- @docker rm -f remark42.bin 2>/dev/null || exit 0
- @mkdir -p bin
docker run -d --name=remark42.bin remark42.bin
docker cp remark42.bin:/artifacts/remark42.linux-amd64.tar.gz bin/remark42.linux-amd64.tar.gz
docker cp remark42.bin:/artifacts/remark42.linux-386.tar.gz bin/remark42.linux-386.tar.gz
docker cp remark42.bin:/artifacts/remark42.linux-arm64.tar.gz bin/remark42.linux-arm64.tar.gz
docker cp remark42.bin:/artifacts/remark42.darwin-amd64.tar.gz bin/remark42.darwin-amd64.tar.gz
docker cp remark42.bin:/artifacts/remark42.darwin-arm64.tar.gz bin/remark42.darwin-arm64.tar.gz
docker cp remark42.bin:/artifacts/remark42.freebsd-amd64.tar.gz bin/remark42.freebsd-amd64.tar.gz
docker cp remark42.bin:/artifacts/remark42.windows-amd64.zip bin/remark42.windows-amd64.zip
docker rm -f remark42.bin
Expand All @@ -39,8 +45,9 @@ frontend:
docker-compose -f compose-dev-frontend.yml build

rundev:
docker pull umputun/baseimage:buildgo-latest
SKIP_BACKEND_TEST=true SKIP_FRONTEND_TEST=true docker-compose -f compose-private.yml build
docker pull umputun/baseimage:buildgo-v1.9.1
SKIP_BACKEND_TEST=true SKIP_FRONTEND_TEST=true GITHUB_REF=$(GITHUB_REF) GITHUB_SHA=$(GITHUB_SHA) CI=true \
docker-compose -f compose-private.yml build
docker-compose -f compose-private.yml up

.PHONY: bin backend
4 changes: 3 additions & 1 deletion compose-dev-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ services:
- SKIP_BACKEND_TEST
- BACKEND_TEST_TIMEOUT
- SKIP_FRONTEND_TEST=true

- CI
- GITHUB_REF
- GITHUB_SHA
image: umputun/remark42:dev
container_name: "remark42-dev"
hostname: "remark42-dev"
Expand Down

0 comments on commit 6309443

Please sign in to comment.