From fab90936cd43772a8b2c4cb296483728789da91b Mon Sep 17 00:00:00 2001 From: Dennis Jekubczyk Date: Mon, 24 May 2021 11:44:04 +0200 Subject: [PATCH] add build --- Dockerfile | 7 ------- Taskfile.yml | 7 ++++++- build/Dockerfile | 15 +++++++++++++++ .dockerignore => build/Dockerfile.dockerignore | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) delete mode 100644 Dockerfile create mode 100644 build/Dockerfile rename .dockerignore => build/Dockerfile.dockerignore (80%) diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 58f47ea..0000000 --- a/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM node:lts-alpine - -WORKDIR /app -COPY package.json package-lock.json ./ -RUN npm ci -COPY . . -CMD [ "/app/docker-entrypoint.sh" ] diff --git a/Taskfile.yml b/Taskfile.yml index c2da11a..119ff53 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -16,13 +16,18 @@ tasks: cmds: - task: lint - task: test + - task: build test: cmds: [ go test ./... ] lint: - desc: lint app + desc: lint cmds: [ third_party/golangci-lint/golangci-lint run ] + build: + desc: build + cmds: [ docker image build -t jaedle/mirror-to-gitea:development -f build/Dockerfile . ] + default: cmds: [ task: world ] diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..cb3daf6 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,15 @@ +FROM golang:1.16-alpine as builder + +WORKDIR /app +ADD . ./ + +RUN ls -al && go build -o main main.go + +FROM scratch as runtime + +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +WORKDIR /app +COPY --from=builder /app/main main + +CMD [ "/app/main" ] diff --git a/.dockerignore b/build/Dockerfile.dockerignore similarity index 80% rename from .dockerignore rename to build/Dockerfile.dockerignore index c522ee9..9cf144e 100644 --- a/.dockerignore +++ b/build/Dockerfile.dockerignore @@ -6,4 +6,4 @@ node_modules/ .gitignore -run-local.sh \ No newline at end of file +run-local.sh