-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start work on all-in-one container deployment
- Loading branch information
1 parent
6dda388
commit 9dfe31b
Showing
6 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |