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

Docker config refactor #104

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ COPY package.json yarn.lock ./

RUN yarn install --frozen-lockfile

FROM node:17-alpine AS builder
FROM deps AS builder

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

ARG API_URL

ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
ENV API_URL=${API_URL:-http://localhost:3000}
ENV NEXT_TELEMETRY_DISABLED=1

COPY . .

RUN yarn build

FROM node:17-alpine AS runner

WORKDIR /app

ARG NODE_ENV

ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=${NODE_ENV:-production}
ENV PORT=3001

EXPOSE ${PORT}

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs

COPY --from=builder /app/next.config.mjs ./
COPY --from=builder /app/public ./public
Expand All @@ -43,8 +43,4 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

ENV PORT=3001

EXPOSE 3001

CMD ["node", "server.js"]
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ services:
server:
build:
context: ./server
args:
- NODE_ENV=production
container_name: server
restart: unless-stopped
user: 1000:1000
Expand All @@ -17,8 +15,8 @@ services:
- WELCOME_TITLE
- ENABLE_ADMIN
- DRIFT_HOME
ports:
- "3000:3000"
# ports:
# - "3000:3000" # only expose if needed
client:
build:
context: ./client
Expand Down
23 changes: 8 additions & 15 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,31 @@ COPY package.json yarn.lock tsconfig.json tslint.json ./

RUN yarn install --frozen-lockfile

FROM node:17-alpine AS builder
FROM deps AS builder

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .

ARG NODE_ENV
ENV NODE_ENV=production

ENV NODE_ENV=${NODE_ENV:-production}
COPY . .

RUN apk add --no-cache git
RUN yarn build:docker

FROM node:17-alpine AS runner

WORKDIR /app

ARG NODE_ENV
ENV NODE_ENV=production
ENV PORT=3000

ENV NODE_ENV=${NODE_ENV:-production}
EXPOSE ${PORT}

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 drift
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 drift

COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules

USER drift

ENV PORT=3000

EXPOSE 3000

CMD ["node", "dist/index.js"]