Skip to content

Commit

Permalink
simplify dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
roschaefer committed Oct 25, 2024
1 parent 3a9b0c1 commit e52438e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 84 deletions.
8 changes: 3 additions & 5 deletions docker/backend.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
ARG APP_IMAGE=ghcr.io/ocelot-social-community/ocelot-social/backend
ARG APP_IMAGE_TAG_BASE=latest-base
ARG APP_IMAGE_TAG_CODE=latest-code
ARG APP_IMAGE_BASE=${APP_IMAGE}:${APP_IMAGE_TAG_BASE}
ARG APP_IMAGE_CODE=${APP_IMAGE}:${APP_IMAGE_TAG_CODE}
FROM $APP_IMAGE_CODE AS build

FROM $APP_IMAGE_BASE AS branded
FROM ghcr.io/ocelot-social-community/ocelot-social/backend:${APP_IMAGE_TAG_CODE} AS build

FROM ghcr.io/ocelot-social-community/ocelot-social/backend:${APP_IMAGE_TAG_BASE} AS branded
COPY --from=build /build .
37 changes: 2 additions & 35 deletions docker/maintenance.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,7 @@
ARG APP_IMAGE=ghcr.io/ocelot-social-community/ocelot-social/maintenance
ARG APP_IMAGE_TAG_BASE=latest-base
ARG APP_IMAGE_TAG_CODE=latest-code
ARG APP_IMAGE_BASE=${APP_IMAGE}:${APP_IMAGE_TAG_BASE}
ARG APP_IMAGE_CODE=${APP_IMAGE}:${APP_IMAGE_TAG_CODE}

##################################################################################
# CODE (branded) #################################################################
##################################################################################
FROM $APP_IMAGE_CODE AS code
FROM ghcr.io/ocelot-social-community/ocelot-social/maintenance:${APP_IMAGE_TAG_CODE} as build

# copy public constants into the Docker image to brand it
COPY ./branding/static/ static/
COPY ./branding/constants/ constants/
RUN /bin/sh -c 'cd constants && for f in *.ts; do mv -- "$f" "${f%.ts}.js"; done'

# locales
COPY ./branding/locales/*.json locales/tmp/
RUN tools/merge-locales.sh

##################################################################################
# BUILD ##########################################################################
##################################################################################
FROM code AS build

# yarn install
## unnicely done in $APP_IMAGE_CODE at the moment, see main repo
# RUN yarn install --production=false --frozen-lockfile --non-interactive
# yarn generate
RUN yarn run generate

##################################################################################
# BRANDED ### TODO # TODO # TODO # TODO # TODO # TODO # TODO # TODO # TODO ####
##################################################################################
# FROM $APP_IMAGE_BASE AS branded
FROM nginx:alpine AS branded

COPY --from=build ./app/dist/ /usr/share/nginx/html/
RUN rm /etc/nginx/conf.d/default.conf
COPY --from=code ./app/maintenance/nginx/custom.conf /etc/nginx/conf.d/
COPY --from=build ./app/maintenance/nginx/custom.conf /etc/nginx/conf.d/default.conf
47 changes: 3 additions & 44 deletions docker/webapp.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,7 @@
ARG APP_IMAGE=ghcr.io/ocelot-social-community/ocelot-social/webapp
ARG APP_IMAGE_TAG_BASE=latest-base
ARG APP_IMAGE_TAG_CODE=latest-code
ARG APP_IMAGE_BASE=${APP_IMAGE}:${APP_IMAGE_TAG_BASE}
ARG APP_IMAGE_CODE=${APP_IMAGE}:${APP_IMAGE_TAG_CODE}

##################################################################################
# CODE (branded) #################################################################
##################################################################################
FROM $APP_IMAGE_CODE AS code
FROM ghcr.io/ocelot-social-community/ocelot-social/webapp:${APP_IMAGE_TAG_CODE} AS build

# locales
RUN tools/merge-locales.sh

##################################################################################
# BUILD ##########################################################################
##################################################################################
FROM code AS build

# yarn install
RUN yarn install --production=false --frozen-lockfile --non-interactive
# yarn build
RUN yarn run build

##################################################################################
# BRANDED (Does contain only "binary"- and static-files to reduce image size) ####
##################################################################################
FROM $APP_IMAGE_BASE AS branded

# TODO - do all copying with one COPY command to have one layer
# Copy "binary"-files from build image
COPY --from=build ${DOCKER_WORKDIR}/.nuxt ./.nuxt
COPY --from=build ${DOCKER_WORKDIR}/node_modules ./node_modules
COPY --from=build ${DOCKER_WORKDIR}/nuxt.config.js ./nuxt.config.js
# Copy static files
# TODO - this seems not be needed anymore for the new rebranding
# TODO - this should be one Folder containign all stuff needed to be copied
COPY --from=build ${DOCKER_WORKDIR}/config/ ./config/
COPY --from=build ${DOCKER_WORKDIR}/constants ./constants
COPY --from=build ${DOCKER_WORKDIR}/static ./static
COPY --from=build ${DOCKER_WORKDIR}/locales ./locales
COPY --from=build ${DOCKER_WORKDIR}/assets/styles/imports ./assets/styles/imports
COPY --from=build ${DOCKER_WORKDIR}/assets/fonts ./assets/fonts
# Copy package.json for script definitions (lock file should not be needed)
COPY --from=build ${DOCKER_WORKDIR}/package.json ./package.json

# Run command
CMD /bin/sh -c "yarn run start"
FROM ghcr.io/ocelot-social-community/ocelot-social/webapp:${APP_IMAGE_TAG_BASE} AS branded
COPY --from=build /build .

0 comments on commit e52438e

Please sign in to comment.