Skip to content

Commit a7df24a

Browse files
authored
Add version and optimised build flags for docker images as well (#286)
1 parent 17fac56 commit a7df24a

File tree

6 files changed

+68
-8
lines changed

6 files changed

+68
-8
lines changed

.dockerignore

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,54 @@
1-
/build/docker
1+
/build/docker
2+
/assets/
3+
4+
# From gitignore:
5+
.vscode
6+
.idea
7+
coverage.out
8+
coverage.html
9+
node_modules
10+
debricked
11+
debricked.exe
12+
dist/
13+
/debricked-go-dependencies.txt
14+
/gomod.debricked.lock
15+
/.env
16+
test/resolve/testdata/pip/requirements.txt.venv/
17+
test/resolve/testdata/pip/requirements.txt.pip.debricked.lock
18+
internal/cmd/scan/testdata/npm/yarn.lock
19+
internal/file/embedded/supported_formats.json
20+
internal/resolution/pm/gradle/.gradle-init-script.debricked.groovy
21+
internal/resolution/pm/nuget/testdata/invalid_dependency/obj
22+
internal/resolution/pm/nuget/testdata/valid/obj
23+
internal/resolution/pm/nuget/testdata/valid/packages.config.nuget.debricked.lock
24+
internal/callgraph/language/java11/testdata/mvnproj/target
25+
test/resolve/testdata/composer/composer.lock
26+
test/resolve/testdata/npm/yarn.lock
27+
test/resolve/testdata/npm/package-lock.json
28+
test/resolve/testdata/bower/bower.debricked.lock
29+
test/resolve/testdata/bower/bower_components/
30+
test/resolve/testdata/nuget/packages.lock.json
31+
test/resolve/testdata/nuget/csproj/packages.lock.json
32+
test/resolve/testdata/nuget/packagesconfig/packages.config.nuget.debricked.lock
33+
test/resolve/testdata/nuget/obj
34+
test/resolve/testdata/nuget/**/obj
35+
debricked.fingerprints.txt
36+
test/resolve/testdata/gomod/gomod.debricked.lock
37+
test/resolve/testdata/maven/maven.debricked.lock
38+
test/callgraph/**/maven.debricked.lock
39+
internal/file/testdata/**/go.sum
40+
internal/file/testdata/**/gomod.debricked.lock
41+
internal/file/testdata/**/yarn-error.log
42+
internal/scan/composer/**/yarn.lock
43+
internal/scan/testdata/**/yarn.lock
44+
internal/scan/testdata/**/package-lock.json
45+
internal/scan/testdata/**/debricked.fingerprints.wfp
46+
test/resolve/testdata/gradle/*/**
47+
**.gradle-init-script.debricked.groovy
48+
test/resolve/testdata/gradle/gradle.debricked.lock
49+
/mvnproj/target
50+
debricked-call-graph.*
51+
internal/scan/testdata/npm/result.json
52+
/internal/file/testdata/misc/yarn.lock
53+
/internal/callgraph/finder/javafinder/testdata/guava/maven.debricked.lock
54+
/internal/resolution/pm/maven/testdata/guava/maven.debricked.lock

.github/workflows/docker.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
steps:
2323
- name: Checkout
2424
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: '50'
27+
fetch-tags: 'true'
2528

2629
- name: Set up QEMU
2730
uses: docker/setup-qemu-action@v3

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: install
22
install:
3-
bash scripts/install.sh
3+
sh scripts/install.sh
44

55
.PHONY: lint
66
lint:

build/docker/alpine.Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
FROM golang:1.22-alpine AS dev
22
WORKDIR /cli
3-
RUN apk update \
4-
&& apk --no-cache --update add git build-base
3+
RUN apk --no-cache --update add git build-base
54
COPY go.mod go.sum ./
65
RUN go mod download && go mod verify
76
COPY . .
87
RUN mkdir -p internal/file/embedded && \
98
wget -O internal/file/embedded/supported_formats.json https://debricked.com/api/1.0/open/files/supported-formats
10-
RUN go build -o debricked ./cmd/debricked
9+
RUN apk add --no-cache make curl && make install && apk del make curl
1110
CMD [ "debricked" ]
1211

1312
FROM alpine:latest AS cli-base

build/docker/debian.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN mkdir -p internal/file/embedded && \
1010
wget -O internal/file/embedded/supported_formats.json https://debricked.com/api/1.0/open/files/supported-formats
1111
RUN go mod download && go mod verify
1212
COPY . .
13-
RUN go build -o debricked ./cmd/debricked
13+
RUN make install
1414
CMD [ "debricked" ]
1515

1616
FROM debian:bookworm-slim AS cli-base

scripts/install.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
25
# test if git is installed
3-
if ! command -v git &> /dev/null
6+
if ! command -v git >/dev/null 2>&1
47
then
58
echo -e "Failed to find git, thus also the version. Version will be set to v0.0.0"
69
fi
10+
set +e
711
version=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)
12+
set -e
813
ldFlags="-s -w -X main.version=${version}"
914
go install -ldflags "${ldFlags}" ./cmd/debricked
1015
go generate -v -x ./cmd/debricked

0 commit comments

Comments
 (0)