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

Aaronkcarpenter patch 2 #2

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
85 changes: 64 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,86 @@
FROM golang:1.21-alpine as builder
# FROM golang:1.21-alpine as builder

ARG REVISION
# RUN mkdir -p /podinfo/

RUN mkdir -p /podinfo/
# WORKDIR /podinfo

WORKDIR /podinfo
# COPY . .

COPY . .
# RUN go mod download

RUN go mod download

RUN CGO_ENABLED=0 go build -ldflags "-s -w \
-X github.com/stefanprodan/podinfo/pkg/version.REVISION=${REVISION}" \
-a -o bin/podinfo cmd/podinfo/*
# ARG REVISION
# RUN CGO_ENABLED=0 go build -ldflags "-s -w \
# -X github.com/stefanprodan/podinfo/pkg/version.REVISION=${REVISION}" \
# -a -o bin/podinfo cmd/podinfo/*

RUN CGO_ENABLED=0 go build -ldflags "-s -w \
-X github.com/stefanprodan/podinfo/pkg/version.REVISION=${REVISION}" \
-a -o bin/podcli cmd/podcli/*
# RUN CGO_ENABLED=0 go build -ldflags "-s -w \
# -X github.com/stefanprodan/podinfo/pkg/version.REVISION=${REVISION}" \
# -a -o bin/podcli cmd/podcli/*

FROM alpine:3.18
# FROM alpine:3.18

# ARG BUILD_DATE
# ARG VERSION
# ARG REVISION

# LABEL maintainer="stefanprodan"

# RUN addgroup -S app \
# && adduser -S -G app app \
# && apk --no-cache add \
# ca-certificates curl netcat-openbsd

# WORKDIR /home/app

# COPY --from=builder /podinfo/bin/podinfo .
# COPY --from=builder /podinfo/bin/podcli /usr/local/bin/podcli
# COPY ./ui ./ui
# RUN chown -R app:app ./

# USER app

# CMD ["./podinfo"]

ARG BUILD_DATE
ARG VERSION

# Use a specific version of the golang image
FROM golang:1.21-alpine as builder

# Create the working directory in one step
WORKDIR /podinfo

# Copy the Go module files first and download dependencies. This leverages Docker's cache to prevent re-downloading dependencies if the go.mod and go.sum files haven't changed.
COPY go.mod go.sum ./
RUN go mod download

# Copy the rest of the source code
COPY . .

# Build the binaries in one step to reduce layers. Also, remove the second build command if it's not necessary.
ARG REVISION
RUN CGO_ENABLED=0 go build -ldflags "-s -w -X github.com/stefanprodan/podinfo/pkg/version.REVISION=${REVISION}" -a -o bin/podinfo cmd/podinfo/*

# Use a specific version of the alpine image
FROM alpine:3.18

# Set labels in one layer
LABEL maintainer="stefanprodan"

RUN addgroup -S app \
&& adduser -S -G app app \
&& apk --no-cache add \
ca-certificates curl netcat-openbsd
# Add the user and group in one command, and only add the ca-certificates package if it's necessary for your application.
RUN addgroup -S app && adduser -S -G app app && apk --no-cache add ca-certificates

# Set the working directory
WORKDIR /home/app

# Copy the necessary files from the builder stage
COPY --from=builder /podinfo/bin/podinfo .
COPY --from=builder /podinfo/bin/podcli /usr/local/bin/podcli
COPY ./ui ./ui
COPY --from=builder /podinfo/ui ./ui

# Set the correct permissions
RUN chown -R app:app ./

# Use the non-root user
USER app

# Set the default command to run the application
CMD ["./podinfo"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/stefanprodan/podinfo)](https://goreportcard.com/report/github.com/stefanprodan/podinfo)
[![Docker Pulls](https://img.shields.io/docker/pulls/stefanprodan/podinfo)](https://hub.docker.com/r/stefanprodan/podinfo)

Podinfo is a tiny web application made with Go that showcases best practices of running microservices in Kubernetes.
Podinfo is a tiny web application made with Go that showcases best practices of running microservices in Kubernetes...,,??--&&
Podinfo is used by CNCF projects like [Flux](https://github.com/fluxcd/flux2) and [Flagger](https://github.com/fluxcd/flagger)
for end-to-end testing and workshops.

Expand Down
2 changes: 1 addition & 1 deletion charts/podinfo/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Podinfo
# PodinfoCheese

Podinfo is a tiny web application made with Go
that showcases best practices of running microservices in Kubernetes.
Expand Down