fix frontend and backend

This commit is contained in:
einhornimmond 2025-05-05 13:39:30 +02:00
parent 5e38ebf3bb
commit ee0e4478f4
4 changed files with 47 additions and 22 deletions

View File

@ -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"]
CMD ["node", "index.js"]

View File

@ -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",

View File

@ -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

View File

@ -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
##################################################################################