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

[FEATURE] Add Separate Dockerfiles for Dev & Production Builds #5699

Open
dwisiswant0 opened this issue Oct 7, 2024 · 1 comment
Open

[FEATURE] Add Separate Dockerfiles for Dev & Production Builds #5699

dwisiswant0 opened this issue Oct 7, 2024 · 1 comment
Assignees
Labels
Type: Enhancement Most issues will probably ask for additions or changes.

Comments

@dwisiswant0
Copy link
Member

Describe your feature request

Splitting the Dockerfiles into two: one for development and one for production.

The development Dockerfile will keep the current multi-stage build process, while the production one will be built from scratch, with no unnecessary dependencies like chromium. This will make the production image leaner, more secure, and easier to maintain.

Describe the use case of the feature

Improve our container deployment process by using a super minimal image for production. Since we don’t need stuff like chromium and other build-related packages in production, the scratch-based image will keep things small and simple, without any extra bloat.

The development Dockerfile will keep all the tools and dependencies needed for local testing and building. The production Dockerfile will be stripped down and optimized for deployment - ready to be pushed to container registries (Docker Hub/GHCR/Artifact Registry). This setup also makes things easier when we need to update/rollback images in cloud envs.

Describe alternatives you've considered

No response

Additional context

Here's what the Dockerfiles would look like:

  1. Development Dockerfile (same as now)

nuclei/Dockerfile

Lines 1 to 15 in c8cc419

# Build
FROM golang:1.21-alpine AS build-env
RUN apk add build-base
WORKDIR /app
COPY . /app
RUN go mod download
RUN go build ./cmd/nuclei
# Release
FROM alpine:3.18.6
RUN apk upgrade --no-cache \
&& apk add --no-cache bind-tools chromium ca-certificates
COPY --from=build-env /app/nuclei /usr/local/bin/
ENTRYPOINT ["nuclei"]

  1. Production Dockerfile
FROM scratch

COPY nuclei /

ENTRYPOINT ["/nuclei"]

The idea is to keep both files in the repo (maybe as Dockerfile for dev and Dockerfile.prod for production). This way, the dev Dockerfile keeps all the build stuff, and the scratch one will be used for production.

Additional references:

@dwisiswant0 dwisiswant0 added the Type: Enhancement Most issues will probably ask for additions or changes. label Oct 7, 2024
@dwisiswant0 dwisiswant0 self-assigned this Oct 7, 2024
@dwisiswant0
Copy link
Member Author

Blocked by #5692

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

No branches or pull requests

1 participant