Skip to content

Commit

Permalink
start work on all-in-one container deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Southclaws committed Dec 10, 2023
1 parent 6dda388 commit 9dfe31b
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 3 deletions.
5 changes: 2 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
home/
web/

.env
.task

data/
node_modules/
web/node_modules/

*.exe
*.db

.DS_Store

__debug_bin
__debug_bin*
71 changes: 71 additions & 0 deletions docker/all/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
FROM golang:latest as api-builder

RUN git config --global --add safe.directory /server

WORKDIR /server
ADD . .

RUN go install github.com/go-task/task/v3/cmd/task@latest
RUN task backend

FROM node:18-alpine AS base

#
# DEPENDENCIES LAYER
#

FROM base AS deps

RUN apk add --no-cache libc6-compat
WORKDIR /app

COPY ./web/package.json ./web/yarn.lock* ./
RUN yarn --frozen-lockfile --ignore-scripts

#
# BUILDER LAYER
#

FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY ./web .

ENV NEXT_TELEMETRY_DISABLED 1

RUN yarn build

#
# RUNTIME IMAGE
#

FROM base AS runner
WORKDIR /app

ENV NODE_ENV production

ENV NEXT_TELEMETRY_DISABLED 1

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

COPY --from=builder /app/public ./public

RUN mkdir .next
RUN chown nextjs:nodejs .next

COPY --from=api-builder --chown=nextjs:nodejs /server/backend.exe ./backend.exe

# Not enabled currently.
# COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000
ENV HOSTNAME "0.0.0.0"

# TODO: Spin up the backend server here too.
CMD ["node", "server.js"]
5 changes: 5 additions & 0 deletions docker/all/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# all

This image contains both the API and the frontend application, all in the same container.

For most small/medium deployments, this should be sufficient.
15 changes: 15 additions & 0 deletions docker/api/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
home/
web/

.env
.task

data/
node_modules/

*.exe
*.db

.DS_Store

__debug_bin
File renamed without changes.
3 changes: 3 additions & 0 deletions docker/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# api

This image contains just the API server. Use this if you want to run the frontend separately, perhaps on Vercel.

0 comments on commit 9dfe31b

Please sign in to comment.