Skip to content

Commit

Permalink
removing security vulnerbilities and decrease the docker image size (#53
Browse files Browse the repository at this point in the history
)

Co-authored-by: kareem.elsaid <kareem.elsaid@d360.com>
  • Loading branch information
kareemelkasaby1 and kareem.elsaid authored Jan 20, 2025
1 parent 2d4f0a5 commit c6b1114
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 58 deletions.
28 changes: 24 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,37 @@
#
# SPDX-License-Identifier: Apache-2.0

FROM golang:1.23.0-alpine3.20
FROM golang:1.23.4-alpine3.21 as builder

Check warning on line 17 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-and-push-image

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

WORKDIR /app

LABEL version="v1.0.0"

# Install ca-certificates and git
RUN sed -i 's/https:/http:/g' /etc/apk/repositories && apk update && apk add --no-cache ca-certificates git && update-ca-certificates

# Set environment variables to bypass SSL verification
ENV GIT_SSL_NO_VERIFY=true
ENV GOPROXY=direct
ENV GOINSECURE=*
ENV GONOSUMDB=*

COPY go.mod go.sum ./
RUN go mod download
RUN go mod tidy

COPY . ./

RUN CGO_ENABLED=0 GOOS=linux go build -o /cbomkit-theia
RUN CGO_ENABLED=0 GOOS=linux go build -o ./cbomkit-theia

FROM alpine:3.21.2

WORKDIR /app

COPY --from=builder /app/cbomkit-theia /app

ENTRYPOINT ["/app/cbomkit-theia"]

EXPOSE 8080
ENTRYPOINT ["/cbomkit-theia"]
CMD ["server"]

CMD [ "server" ]
36 changes: 18 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ go 1.23.0
require (
github.com/CycloneDX/cyclonedx-go v0.9.1
github.com/anchore/go-logger v0.0.0-20240217160628-ee28a485904f
github.com/anchore/stereoscope v0.0.3
github.com/docker/docker v27.3.1+incompatible
github.com/anchore/stereoscope v0.0.12
github.com/docker/docker v27.4.1+incompatible
github.com/dominikbraun/graph v0.23.0
github.com/gabriel-vasile/mimetype v1.4.5
github.com/gabriel-vasile/mimetype v1.4.8
github.com/gin-contrib/cors v1.7.2
github.com/gin-gonic/gin v1.10.0
github.com/google/go-cmp v0.6.0
Expand All @@ -18,12 +18,12 @@ require (
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
github.com/xeipuuv/gojsonschema v1.2.0
github.com/zricethezav/gitleaks/v8 v8.19.3
go.mozilla.org/pkcs7 v0.9.0
go.uber.org/dig v1.18.0
golang.org/x/crypto v0.27.0
golang.org/x/crypto v0.32.0
)

require (
Expand All @@ -32,22 +32,22 @@ require (
github.com/BobuSumisu/aho-corasick v1.0.3 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.12.6 // indirect
github.com/adrg/xdg v0.5.0 // indirect
github.com/adrg/xdg v0.5.3 // indirect
github.com/anchore/go-collections v0.0.0-20240216214351-5baf374cca6f // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/becheran/wildmatch-go v1.0.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/bmatcuk/doublestar/v4 v4.7.1 // indirect
github.com/bytedance/sonic v1.12.2 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/charmbracelet/lipgloss v0.13.0 // indirect
github.com/charmbracelet/x/ansi v0.2.3 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/containerd/cgroups/v3 v3.0.3 // indirect
github.com/containerd/containerd v1.7.20 // indirect
github.com/containerd/containerd v1.7.24 // indirect
github.com/containerd/containerd/api v1.7.19 // indirect
github.com/containerd/continuity v0.4.3 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/errdefs v0.3.0 // indirect
github.com/containerd/fifo v1.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
Expand All @@ -56,7 +56,7 @@ require (
github.com/containerd/typeurl/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/cli v27.1.2+incompatible // indirect
github.com/docker/cli v27.4.1+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.2 // indirect
github.com/docker/go-connections v0.5.0 // indirect
Expand All @@ -71,7 +71,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.22.1 // indirect
github.com/go-playground/validator/v10 v10.24.0 // indirect
github.com/go-test/deep v1.1.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand Down Expand Up @@ -125,8 +125,8 @@ require (
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/sylabs/sif/v2 v2.19.1 // indirect
github.com/sylabs/squashfs v1.0.0 // indirect
github.com/sylabs/sif/v2 v2.20.2 // indirect
github.com/sylabs/squashfs v1.0.4 // indirect
github.com/therootcompany/xz v1.0.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
Expand All @@ -145,11 +145,11 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.10.0 // indirect
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto v0.0.0-20240823204242-4ba0660f739c // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240823204242-4ba0660f739c // indirect
google.golang.org/grpc v1.65.0 // indirect
Expand Down
Loading

0 comments on commit c6b1114

Please sign in to comment.