Commit 61a531dd authored by blackheaven's avatar blackheaven
Browse files

Update dockerize

parent da552d67
Loading
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+27 −0
Original line number Diff line number Diff line
image: docker:stable

variables:
  BUILDX_VERSION: v0.10.4
  BUILDX_ARCH: linux-amd64

services:
  - docker:dind

build:
  stage: build
  tags:
    - amd64
  before_script:
    - mkdir -p $HOME/.docker/cli-plugins/
    - wget -O $HOME/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.${BUILDX_ARCH}
    - chmod +x $HOME/.docker/cli-plugins/docker-buildx
    - docker run --privileged --rm tonistiigi/binfmt --install all
    - docker buildx create --use
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  script:
    - docker buildx build
      --platform linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le,linux/s390x,linux/386
      -t ${CI_REGISTRY_IMAGE}:latest
      -f ./Dockerfile
      --push
      .

Dockerfile

0 → 100644
+24 −0
Original line number Diff line number Diff line
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.18-alpine AS Builder

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

RUN apk add --no-cache git build-base upx
RUN git clone -b master --single-branch https://github.com/taironas/tinygraphs.git /app

WORKDIR /app
RUN go mod tidy
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -ldflags="-s -w"; \
    upx --best --lzma /app/tinygraphs

FROM --platform=${TARGETPLATFORM:-linux/amd64} scratch

COPY --from=builder /app/app /app/
COPY --from=builder /app/tinygraphs /app/tinygraphs

ENV PORT=8080
EXPOSE 8080

CMD ["/app/tinygraphs"]
 No newline at end of file