Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset API #22

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Allowlisting gitignore template for GO projects prevents us
# from adding various unwanted local files, such as generated
# files, developer configurations or IDE-specific files etc.
#
# Recommended: Go.AllowList.gitignore

# Ignore everything
*

# But not these files...
!/.gitignore

!*.go
!go.sum
!go.mod

!README.md
!LICENSE

!docker-compose.yml
!Dockerfile

!swagger.json
!GoFavourites.postman_collection.json
!GoFavourites.postman_environment.json
# !Makefile

# ...even if they are in subdirectories
!*/
100 changes: 100 additions & 0 deletions AUDIENCE_MOCK_DATA.json

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions CHARTS_MOCK_DATA.json

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Use the official Golang image to create a build artifact.
# This is the first stage called "builder".
FROM golang:1.23-rc as builder

Check failure on line 3 in Dockerfile

View check run for this annotation

Wiz GWI / Wiz IaC Scanner

Missing User Instruction

Rule ID: 0b5e0683-5a06-4bcd-ac73-28249add06df Severity: High Resource: FROM={{golang:1.23-rc}} A user should be specified in the dockerfile, otherwise the image will run as root
Raw output
Expected: The 'Dockerfile' should contain the 'USER' instruction
Found: The 'Dockerfile' does not contain any 'USER' instruction

Check notice on line 3 in Dockerfile

View check run for this annotation

Wiz GWI / Wiz IaC Scanner

Healthcheck Instruction Missing

Rule ID: 704ee966-67b2-4219-871f-12a7e5126cb1 Severity: Low Resource: FROM={{golang:1.23-rc}} Ensure that HEALTHCHECK is being used. The HEALTHCHECK instruction tells Docker how to test a container to check that it is still working
Raw output
Expected: Dockerfile should contain instruction 'HEALTHCHECK'
Found: Dockerfile doesn't contain instruction 'HEALTHCHECK'

# Set the Current Working Directory inside the container
WORKDIR /app

# Copy go mod and sum files
COPY go.mod go.sum ./

# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed.
RUN go mod download

# Copy the source from the current directory to the Working Directory inside the container
COPY . .

# Build the Go app
RUN go build -o main .

# Start a new stage from scratch
FROM golang:1.23-rc

# Set the Current Working Directory inside the container
WORKDIR /app

# Copy the Pre-built binary file from the previous stage
COPY --from=builder /app/main .

# Expose port 8080 to the outside world
EXPOSE 8080

# Command to run the executable
CMD ["./main"]
41 changes: 41 additions & 0 deletions Dockerfile-swagger
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Use the official Golang image to create a build artifact.
# This is the first stage called "builder".
FROM golang:1.23-rc as builder

# Set the Current Working Directory inside the container
WORKDIR /app

# Copy go mod and sum files
COPY go.mod go.sum ./

# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed.
RUN go mod download

# Copy the source from the current directory to the Working Directory inside the container
COPY . .

# Build the Go app
RUN go build -o main .

FROM ghcr.io/go-swagger/go-swagger

Check failure on line 20 in Dockerfile-swagger

View check run for this annotation

Wiz GWI / Wiz IaC Scanner

Missing User Instruction

Rule ID: 0b5e0683-5a06-4bcd-ac73-28249add06df Severity: High Resource: FROM={{ghcr.io/go-swagger/go-swagger}} A user should be specified in the dockerfile, otherwise the image will run as root
Raw output
Expected: The 'Dockerfile' should contain the 'USER' instruction
Found: The 'Dockerfile' does not contain any 'USER' instruction

Check warning on line 20 in Dockerfile-swagger

View check run for this annotation

Wiz GWI / Wiz IaC Scanner

Image Version Not Explicit

Rule ID: 74c1e114-b7e9-43ca-bd0d-5d10d48ab234 Severity: Medium Resource: FROM={{ghcr.io/go-swagger/go-swagger}} Always tag the version of an image explicitly
Raw output
Expected: FROM ghcr.io/go-swagger/go-swagger:'version'
Found: FROM ghcr.io/go-swagger/go-swagger'

Check notice on line 20 in Dockerfile-swagger

View check run for this annotation

Wiz GWI / Wiz IaC Scanner

Healthcheck Instruction Missing

Rule ID: 704ee966-67b2-4219-871f-12a7e5126cb1 Severity: Low Resource: FROM={{ghcr.io/go-swagger/go-swagger}} Ensure that HEALTHCHECK is being used. The HEALTHCHECK instruction tells Docker how to test a container to check that it is still working
Raw output
Expected: Dockerfile should contain instruction 'HEALTHCHECK'
Found: Dockerfile doesn't contain instruction 'HEALTHCHECK'

# Set the Current Working Directory inside the container
WORKDIR /app

ENV GOBIN $GOPATH/bin

COPY --from=builder /app ./

ADD . .

Check notice on line 29 in Dockerfile-swagger

View check run for this annotation

Wiz GWI / Wiz IaC Scanner

Add Instead of Copy

Rule ID: 87713019-69f1-4ab3-8d33-5d2aca688663 Severity: Low Resource: FROM={{ghcr.io/go-swagger/go-swagger}}.{{ADD . .}} Should use COPY instead of ADD unless, running a tar file
Raw output
Expected: 'COPY' .
Found: 'ADD' .

## Commands for swagger docs generation
# swagger generate spec -o ./swagger.json --scan-models
# swagger validate swagger.json
# swagger serve swagger.json -p=6060 --no-open

#RUN swagger generate spec -o swagger.json --scan-models

ENTRYPOINT swagger serve swagger.json -p 6060 --no-open

Check warning on line 38 in Dockerfile-swagger

View check run for this annotation

Wiz GWI / Wiz IaC Scanner

Not Using JSON In CMD And ENTRYPOINT Arguments

Rule ID: 31ec411f-5a9c-42e3-9735-6ae93ff49d1f Severity: Medium Resource: FROM={{ghcr.io/go-swagger/go-swagger}}.{{ENTRYPOINT swagger serve swagger.json -p 6060 --no-open}} Ensure that we are using JSON in the CMD and ENTRYPOINT Arguments
Raw output
Expected: FROM={{ghcr.io/go-swagger/go-swagger}}.{{ENTRYPOINT  swagger serve swagger.json -p 6060 --no-open}} is in the JSON Notation
Found: FROM={{ghcr.io/go-swagger/go-swagger}}.{{ENTRYPOINT  swagger serve swagger.json -p 6060 --no-open}} isn't in the JSON Notation

# serving HTTP of 6060
EXPOSE 6060
Loading