Skip to content

Commit

Permalink
Fix failing regoval tests due to Dockerfile in .gitignore
Browse files Browse the repository at this point in the history
Signed-off-by: Santosh <[email protected]>
  • Loading branch information
santoshkal committed Jun 17, 2024
1 parent a08b817 commit 884f56a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ cosign
!.devcontainer/Dockerfile
results.json
.env
!pkg/validate/testdata/Dockerfile/
3 changes: 0 additions & 3 deletions cmd/regoval_dockerfileval.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ func init() {
log.Fatalf("Error marking flag as required: %v", err)
}
dockerfilevalCmd.Flags().StringVarP(&dockerfilevalArgs.policy, "policy", "p", "", "Path for the Rego policy file, polciy can be passed from either Local or from remote URL")
// if err := dockerfilevalCmd.MarkFlagRequired("policy"); err != nil {
// log.Fatalf("Error marking flag as required: %v", err)
// }

regovalCmd.AddCommand(dockerfilevalCmd)
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/validate/regoval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestValidateWithRego(t *testing.T) {
},
{
name: "valid Dockerfile and policy",
inputContent: "Dockerfile",
inputContent: "Docker-file",
regoPolicy: "/rego/dockerfilepolicies/",
expectedError: false,
},
Expand Down
42 changes: 42 additions & 0 deletions pkg/validate/testdata/Docker-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Stage 1: Build the application
FROM cgr.dev/chainguard/wolfi-base AS builder

RUN --no-cache apk update && apk add python-3.11 && \
apk add py3.11-pip --no-cache
USER nonroot

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
EXPOSE 22
USER nonroot

WORKDIR /app

COPY --chown=nonroot:nonroot requirements.txt /app/requirements.txt

RUN pip install -r /app/requirements.txt --user


# Stage 2: Copy the venv and run the application
FROM cgr.dev/chainguard/wolfi-base AS final

RUN --no-cache apk update && apk add python-3.11 && \
apk add py3.11-pip

RUN pip install --upgrade pip setuptools

USER nonroot

WORKDIR /app

ENV PYTHONUNBUFFERED=1

COPY --chown=nonroot:nonroot . .

COPY --from=builder --chown=nonroot:nonroot /home/nonroot/.local /home/nonroot/.local

ENV PATH=/home/nonroot/.local/bin:$PATH

EXPOSE 8000

CMD ["uvicorn", "main:app","--host", "0.0.0.0","--port", "8000"]

0 comments on commit 884f56a

Please sign in to comment.