Skip to content

Commit

Permalink
update deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidOkulski committed Jan 6, 2025
1 parent e67d6ce commit 1219b6c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
5 changes: 2 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
services:
app:
build: .
build:
context: .
ports:
- "${APP_PORT}:${APP_PORT}"
env_file:
- .env
depends_on:
- db
volumes:
- .:/usr/src/app
restart: always
command: >
sh -c "npx knex migrate:latest && node index.js"
Expand Down
11 changes: 10 additions & 1 deletion dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
FROM node:18
FROM node:20

# Set allowed UID/GID range and create non-root user
ARG ALLOWED_UID=1007250000
ARG ALLOWED_GID=1007250000

RUN addgroup --gid ${ALLOWED_GID} appgroup && \
adduser --disabled-password --gecos "" --uid ${ALLOWED_UID} --gid ${ALLOWED_GID} appuser

WORKDIR /usr/app

Expand All @@ -21,6 +28,8 @@ RUN npm run build

WORKDIR /usr/app/src

USER appuser

ARG APP_PORT
ENV APP_PORT=${APP_PORT}
EXPOSE ${APP_PORT}
Expand Down
24 changes: 6 additions & 18 deletions helm/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: StatefulSet
metadata:
name: {{ .Release.Name }}-postgresql
labels:
app: {{ .Release.Name }}
app: {{ .Release.Name }}-postgresql
spec:
replicas: 1
serviceName: {{ .Release.Name }}-postgresql
Expand All @@ -16,33 +16,21 @@ spec:
app: {{ .Release.Name }}-postgresql
spec:
securityContext:
fsGroup: 1000
initContainers:
- name: fix-permissions
image: busybox
command: ["sh", "-c", "chmod -R 777 /var/lib/postgresql/data"]
securityContext:
runAsUser: 0
volumeMounts:
- name: data
mountPath: /var/lib/postgresql/data
fsGroup: 999
containers:
- name: postgresql
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
securityContext:
runAsUser: 1000
allowPrivilegeEscalation: false
image: "{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}"
ports:
- containerPort: {{ .Values.service.postgresPort }}
env:
- name: POSTGRES_USER
value: {{ .Values.postgresql.username }}
- name: POSTGRES_PASSWORD
value: {{ .Values.postgresql.password }}
- name: POSTGRES_DB
value: {{ .Values.postgresql.database }}
- name: POSTGRES_INITDB_ARGS
value: "--no-locale --data-checksums --no-permission-check"
volumeMounts:
- name: data
- name: pgdata
mountPath: /var/lib/postgresql/data
volumeClaimTemplates:
- metadata:
Expand Down

0 comments on commit 1219b6c

Please sign in to comment.