-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from BlazingTwist/18-support-docker-containers
18 support docker containers
- Loading branch information
Showing
16 changed files
with
157 additions
and
50 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM maven:3-amazoncorretto-21 as build | ||
COPY src/main/java src/main/java | ||
COPY src/main/resources src/main/resources | ||
COPY src/test src/test | ||
COPY pom.xml pom.xml | ||
RUN mvn package -f pom.xml | ||
|
||
FROM amazoncorretto:21 | ||
COPY --from=build /target/jchess.jar /app/jchess.jar | ||
COPY --from=build /target/lib /app/lib | ||
CMD ["java", "-jar", "/app/jchess.jar"] |
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
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,17 @@ | ||
services: | ||
backend: | ||
build: . | ||
ports: | ||
- "8880:8880" | ||
expose: | ||
- "8880" | ||
environment: | ||
- IS_DOCKER=true | ||
frontend: | ||
build: | ||
context: ./src/main/ | ||
dockerfile: ./jchess-web/Dockerfile | ||
args: | ||
backend_port: 8880 | ||
ports: | ||
- "3000:3000" |
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
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
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
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
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,5 +1,4 @@ | ||
NEXT_PUBLIC_JCHESS_UNDERTOW_SERVER_URI=http://127.0.0.1:8880 | ||
NEXT_PUBLIC_JCHESS_SOCKET_URI=ws://localhost:8880 | ||
NEXT_PUBLIC_CLIENT_URI=http://localhost:3000 | ||
NEXT_PUBLIC_BOARD_WITH_COORDINATES=false | ||
NEXT_PUBLIC_LOCAL_STORAGE=false | ||
NEXT_PUBLIC_LOCAL_STORAGE=false |
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,80 @@ | ||
ARG backend_port | ||
|
||
# https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile | ||
FROM node:18-alpine AS base | ||
|
||
|
||
# Rebuild the source code only when needed | ||
FROM base AS builder | ||
ARG backend_port | ||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
COPY jchess-web/package.json jchess-web/package-lock.json* ./ | ||
COPY ./jchess-web/app app | ||
COPY ./jchess-web/components components | ||
COPY ./jchess-web/pages pages | ||
COPY ./jchess-web/public public | ||
COPY ./jchess-web/services services | ||
COPY ./jchess-web/utils utils | ||
COPY ./jchess-web/.eslintrc.json .eslintrc.json | ||
COPY ./jchess-web/components.json components.json | ||
COPY ./jchess-web/next.config.js next.config.js | ||
COPY ./jchess-web/postcss.config.js postcss.config.js | ||
COPY ./jchess-web/tailwind.config.ts tailwind.config.ts | ||
COPY ./jchess-web/tsconfig.json tsconfig.json | ||
COPY ./resources/dx ./resources/dx | ||
|
||
RUN npm i | ||
RUN npm install -g json-schema-to-typescript | ||
RUN json2ts -i ./resources/dx/schema/ -o ./models --cwd ./resources/dx/schema/types | ||
|
||
# Next.js collects completely anonymous telemetry data about general usage. | ||
# Learn more here: https://nextjs.org/telemetry | ||
# Uncomment the following line in case you want to disable telemetry during the build. | ||
# ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
# see .env.example | ||
ENV NEXT_PUBLIC_JCHESS_UNDERTOW_SERVER_URI "http://backend:$backend_port" | ||
# verwirrend, aber: http Requests werden auf dem Server aufgelöst, Sockets auf dem Client | ||
# -> PROBLEM: dann stimmt die Addresse hier natürlich nur, wenn man den Server selbst hostet... (TODO erja) | ||
ENV NEXT_PUBLIC_JCHESS_SOCKET_URI "ws://localhost:$backend_port" | ||
ENV NEXT_PUBLIC_BOARD_WITH_COORDINATES "false" | ||
ENV NEXT_PUBLIC_LOCAL_STORAGE "false" | ||
|
||
RUN npm run build | ||
|
||
# Production image, copy all the files and run next | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
# Uncomment the following line in case you want to disable telemetry during runtime. | ||
# ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
|
||
# Set the correct permission for prerender cache | ||
RUN mkdir .next | ||
RUN chown nextjs:nodejs .next | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
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 | ||
# set hostname to localhost | ||
ENV HOSTNAME "0.0.0.0" | ||
|
||
# server.js is created by next build from the standalone output | ||
# https://nextjs.org/docs/pages/api-reference/next-config-js/output | ||
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
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
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
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
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 @@ | ||
// Ordner ist aktuell leer, aber die Dockerfile schlägt fehl, wenn er fehlt..... |
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
Oops, something went wrong.