Skip to content

Commit

Permalink
fix: improve docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Nov 7, 2023
1 parent c9b4cda commit 4e5c91b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.bin/
.config-db/
.github/
.vscode/

build

chart/
CONTRIBUTING.md
SECURITY.md
README.md
PROJECT

cover.out
.releaserc
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GOBIN=$(shell go env GOBIN)
endif

docker:
docker build . -t ${IMG}
docker build . -f build/Dockerfile -t ${IMG}

# Push the docker image
docker-push:
Expand Down
14 changes: 10 additions & 4 deletions Dockerfile → build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM golang:1.20@sha256:bc5f0b5e43282627279fe5262ae275fecb3d2eae3b33977a7fd200c7a760d6f1 as builder
WORKDIR /app
COPY ./ ./

ARG VERSION

COPY go.mod /app/go.mod
COPY go.sum /app/go.sum
RUN go mod download
WORKDIR /app
RUN go version

COPY ./ ./
RUN make build

FROM ubuntu:jammy@sha256:0bced47fffa3361afa981854fcabcd4577cd43cebbb808cea2b1f33a3dd7f508
Expand All @@ -16,5 +16,11 @@ WORKDIR /app
COPY --from=builder /app/.bin/config-db /app
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

RUN mkdir /opt/database && groupadd --gid 1000 catalog && \
useradd catalog --uid 1000 -g catalog -m -d /var/lib/catalog && \
chown -R 1000:1000 /opt/database && chown -R 1000:1000 /app

USER catalog:catalog

RUN /app/config-db go-offline
ENTRYPOINT ["/app/config-db"]
ENTRYPOINT ["/app/config-db"]
2 changes: 1 addition & 1 deletion chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ description: A Helm chart for config-db

type: application

version: 0.2.0
version: 0.3.0

appVersion: "0.0.5"
2 changes: 2 additions & 0 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ spec:
labels: {{- include "config-db.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ template "config-db.serviceAccountName" . }}
securityContext:
fsGroup: 1000
containers:
- name: {{ include "config-db.name" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand Down

0 comments on commit 4e5c91b

Please sign in to comment.