Skip to content

Commit

Permalink
Merge pull request #35 from Ilyes512/updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilyes512 authored Oct 8, 2023
2 parents 68e29a7 + d5ca9f5 commit 27ecacf
Show file tree
Hide file tree
Showing 12 changed files with 1,777 additions and 961 deletions.
22 changes: 12 additions & 10 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/kubico
/.git
/.vscode
/assets
!/assets/dist
/.dockerignore
/.editorconfig
/.env
/.gitignore
/kubico
/README.md
/Taskfile.yml
/.hadolint.yml
/.github
/dist
/assets/node_modules
.dockerignore
.editorconfig
.env
.gitignore
README.md
Taskfile.dist.yml
Taskfile.yml
.hadolint.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.task
/kubico
/dist
29 changes: 18 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
FROM golang:1.20.7-bullseye AS builder
FROM node:18.18.0-bullseye AS node

WORKDIR /src/assets

COPY ./assets/package*.json .

RUN npm ci

COPY ./assets .
COPY ./templates ../templates

RUN npm run prod

FROM golang:1.21.2-bookworm AS builder

WORKDIR /src

RUN apt-get update \
&& apt-get install --assume-yes --no-install-recommends \
ca-certificates \
upx
ca-certificates

COPY go.mod .
COPY go.sum .
Expand All @@ -14,19 +26,14 @@ RUN go mod download

COPY . .

COPY --from=node /src/dist dist

ARG GOARCH=amd64

RUN go generate \
&& CGO_ENABLED=0 GOOS=linux GOARCH=$GOARCH go build -a -tags netgo -ldflags '-extldflags "-static" -s -w' -o ./kubico

ARG COMPRESS=false

RUN echo compress \
&& echo $COMPRESS

RUN if [ $COMPRESS = 1 ]; then upx --brute --no-progress ./kubico; fi

FROM debian:11.6-slim AS debian
FROM debian:12.1-slim AS debian

COPY --from=builder /src/kubico /usr/local/bin

Expand Down
26 changes: 20 additions & 6 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ vars:
# Latatest version of Hadolint: https://hub.docker.com/r/hadolint/hadolint/tags or https://github.com/hadolint/hadolint/releases
HADOLINT_TAG_VERSION: v2.12.0
EXE: kubico{{exeExt}}
NODE_TAG_VERSION: 18.14.0-bullseye
# Latest version of Node: https://hub.docker.com/_/node/
NODE_TAG_VERSION: 18.18.0-bullseye
NODE_NPM_VOLUME: kubico_node_npm

tasks:
Expand Down Expand Up @@ -45,8 +46,15 @@ tasks:
desc: Build docker container
deps: [d:lint]
cmds:
- docker build --tag {{.DOCKER_REPO}}/{{.DOCKER_OWNER}}/{{.DOCKER_IMAGE_NAME}}:debian --build-arg=GOARCH={{ARCH}} --build-arg=COMPRESS={{.COMPRESS | default 0}} --target debian .
- docker build --tag {{.DOCKER_REPO}}/{{.DOCKER_OWNER}}/{{.DOCKER_IMAGE_NAME}}:scratch --build-arg=GOARCH={{ARCH}} --build-arg=COMPRESS={{.COMPRESS | default 0}} .
- docker build
--tag {{.DOCKER_REPO}}/{{.DOCKER_OWNER}}/{{.DOCKER_IMAGE_NAME}}:debian
--build-arg=GOARCH={{ARCH}}
--target debian
.
- docker build
--tag {{.DOCKER_REPO}}/{{.DOCKER_OWNER}}/{{.DOCKER_IMAGE_NAME}}:scratch
--build-arg=GOARCH={{ARCH}}
.

d:run:
desc: Run the container
Expand All @@ -56,7 +64,13 @@ tasks:
ENV_EXISTS:
sh: if [ -s .env ]; then echo 1; else echo 0; fi
cmds:
- docker run --tty --interactive --rm --publish 8080:8080 {{if eq .ENV_EXISTS "1"}}--volume $(pwd)/.env:/.env{{end}} {{.DOCKER_REPO}}/{{.DOCKER_OWNER}}/{{.DOCKER_IMAGE_NAME}}:scratch;
- docker run
--tty
--interactive
--rm
--publish 8080:8080
{{if eq .ENV_EXISTS "1"}} --volume $(pwd)/.env:/.env {{end}}
{{.DOCKER_REPO}}/{{.DOCKER_OWNER}}/{{.DOCKER_IMAGE_NAME}}:scratch

d:lint:
desc: Apply a Dockerfile linter (https://github.com/hadolint/hadolint)
Expand All @@ -75,6 +89,7 @@ tasks:
# NODE / NPM
#
########################################################################################################################

node:run:
cmds:
- docker run
Expand All @@ -83,8 +98,7 @@ tasks:
--tty
--env npm_config_cache=/tmp/npmcache
--user $(id -u):$(id -g)
--volume $(pwd)/assets:/src/assets
--volume $(pwd)/templates:/src/templates
--volume $(pwd):/src
--workdir /src/assets
node:{{.NODE_TAG_VERSION}} {{.RUN_CMD}}

Expand Down
1 change: 0 additions & 1 deletion assets/dist/tailwind.css

This file was deleted.

Loading

0 comments on commit 27ecacf

Please sign in to comment.