From 53ec5ba7f48326ba304c16e5722647a2ed83a359 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 5 May 2025 13:39:30 +0200 Subject: [PATCH] fix frontend and backend --- backend/Dockerfile | 22 ++++++++++++++++++---- backend/package.json | 1 - docker-compose.yml | 16 ++++------------ frontend/Dockerfile | 30 +++++++++++++++++++++++++----- 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 4dee9953c..ff2ce19b4 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -16,6 +16,8 @@ ENV BUILD_COMMIT="0000000" ENV NODE_ENV="production" ## App relevant Envs ENV PORT="4000" +## Timezone +ENV TZ=UTC # Labels LABEL org.label-schema.build-date="${BUILD_DATE}" @@ -33,6 +35,9 @@ LABEL maintainer="support@gradido.net" # Install Additional Software ## install: git #RUN apk --no-cache add git +RUN yarn global add bun +# Add bun's global bin directory to PATH +ENV PATH="/root/.bun/bin:${PATH}" # Settings ## Expose Container Port @@ -42,6 +47,14 @@ EXPOSE ${PORT} RUN mkdir -p ${DOCKER_WORKDIR} WORKDIR ${DOCKER_WORKDIR} +################################################################################## +# Development #################################################################### +################################################################################## +FROM base AS development + + +# Run command +CMD /bin/sh -c "bun install --frozen-lockfile && bun turbo backend#dev --env-mode=loose" ################################################################################## # Base with turbo ################################################################ @@ -49,9 +62,8 @@ WORKDIR ${DOCKER_WORKDIR} FROM base as turbo-base RUN apk update && apk add --no-cache libc6-compat \ - && yarn global add turbo@^2 \ - && rm -rf /tmp/* ~/.cache node_modules/.cache \ - && yarn cache clean + && bun add --global turbo@^2 \ + && rm -rf /tmp/* ~/.cache node_modules/.cache ################################################################################## # BUILDER (create partly monorepo only with data needed by backend) ############## @@ -105,5 +117,7 @@ COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/backend/log4js-config.js # Copy locales COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/backend/locales ./locales +ENV NODE_ENV=production + # Run command -CMD ["TZ=UTC", "node", "index.js"] \ No newline at end of file +CMD ["node", "index.js"] \ No newline at end of file diff --git a/backend/package.json b/backend/package.json index 7fd3a4962..84cd523c3 100644 --- a/backend/package.json +++ b/backend/package.json @@ -10,7 +10,6 @@ "scripts": { "build": "ts-node ./esbuild.config.ts && mkdirp build/templates/ && ncp src/emails/templates build/templates && mkdirp locales/ && ncp src/locales locales", "clean": "tsc --build --clean", - "start:node": "cross-env TZ=UTC NODE_ENV=production TS_NODE_BASEURL=./build node -r tsconfig-paths/register build/src/index.js", "start": "cross-env TZ=UTC NODE_ENV=production node build/index.js", "dev": "cross-env TZ=UTC nodemon -w src --ext ts,pug,json,css -r tsconfig-paths/register src/index.ts", "typecheck": "tsc --noEmit", diff --git a/docker-compose.yml b/docker-compose.yml index d5ea2548f..bcee473ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,9 +10,7 @@ services: ######################################################## frontend: # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there - image: gradido/frontend:local-production - env_file: - - .env.git + image: gradido/frontend:local-production build: context: ./ dockerfile: ./frontend/Dockerfile @@ -93,8 +91,6 @@ services: backend: # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there image: gradido/backend:local-production - env_file: - - .env.git build: # since we have to include the entities from ./database we cannot define the context as ./backend # this might blow build image size to the moon ?! @@ -114,7 +110,7 @@ services: - BUILD_DATE - BUILD_VERSION - BUILD_COMMIT - - NODE_ENV="production" + - NODE_ENV=production - DB_HOST=mariadb # Application only envs #env_file: @@ -129,8 +125,6 @@ services: dht-node: # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there image: gradido/dht-node:local-production - env_file: - - .env.git build: # since we have to include the entities from ./database we cannot define the context as ./backend # this might blow build image size to the moon ?! @@ -172,6 +166,8 @@ services: context: . dockerfile: ./dlt-connector/Dockerfile target: production + profiles: + - dlt networks: - internal-net - external-net @@ -197,8 +193,6 @@ services: federation: # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there image: gradido/federation:local-production - env_file: - - .env.git build: # since we have to include the entities from ./database we cannot define the context as ./federation # this might blow build image size to the moon ?! @@ -233,8 +227,6 @@ services: database: # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there image: gradido/database:local-up - env_file: - - .env.git build: context: . dockerfile: ./database/Dockerfile diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 09a5bb8b9..9482d8e88 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -19,6 +19,8 @@ ENV BUILD_COMMIT_SHORT=${BUILD_COMMIT_SHORT} ENV NODE_ENV="production" ## App relevant Envs ENV PORT="3000" +## Timezone +ENV TZ=UTC # Labels LABEL org.label-schema.build-date="${BUILD_DATE}" @@ -35,7 +37,10 @@ LABEL maintainer="support@ogradido.net" # Install Additional Software ## install: node-gyp dependencies -RUN apk --no-cache add g++ make python3 +#RUN apk --no-cache add g++ make python3 +RUN yarn global add bun +# Add bun's global bin directory to PATH +ENV PATH="/root/.bun/bin:${PATH}" # Settings ## Expose Container Port @@ -45,16 +50,27 @@ EXPOSE ${PORT} RUN mkdir -p ${DOCKER_WORKDIR} WORKDIR ${DOCKER_WORKDIR} + +################################################################################## +# Development #################################################################### +################################################################################## +FROM base AS development + +# used for getting git commit hash direct from .git +RUN apk update && apk add --no-cache git + +# Run command +CMD /bin/sh -c "bun install --frozen-lockfile && bun turbo frontend#dev --env-mode=loose" + + ################################################################################## # Base with turbo ################################################################ ################################################################################## FROM base as turbo-base RUN apk update && apk add --no-cache libc6-compat \ - && yarn global add turbo@^2 \ - && rm -rf /tmp/* ~/.cache node_modules/.cache \ - && yarn cache clean - + && bun add --global turbo@^2 \ + && rm -rf /tmp/* ~/.cache node_modules/.cache ################################################################################## # BUILDER (create partly monorepo only with data needed by frontend) ############# @@ -77,6 +93,10 @@ RUN yarn install --frozen-lockfile --production=false \ # Build the project COPY --chown=app:app --from=builder /app/out/full/ . +# TODO: get the actually git commit hash into docker +ENV BUILD_COMMIT='deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' +ENV BUILD_COMMIT_SHORT='deadbeef' +ENV BUILD_VERSION='broken' RUN turbo build --env-mode=loose ##################################################################################