Skip to content

Commit

Permalink
separate named image repos for targets
Browse files Browse the repository at this point in the history
+ better naming
+ removed obsolete stages
  • Loading branch information
roschaefer committed Oct 27, 2024
1 parent b64ab38 commit 86993ce
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 127 deletions.
42 changes: 16 additions & 26 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,42 @@ jobs:
context: neo4j
file: neo4j/Dockerfile
target: community
suffix:
- name: backend
- name: backend-base
context: backend
file: backend/Dockerfile
target: base
suffix: -base
- name: backend
- name: backend-build
context: backend
file: backend/Dockerfile
target: code
suffix: -code
target: build
- name: backend
context: backend
file: backend/Dockerfile
target: production
suffix:
- name: webapp
- name: webapp-base
context: webapp
file: webapp/Dockerfile
target: base
suffix: -base
- name: webapp
- name: webapp-build
context: webapp
file: webapp/Dockerfile
target: code
suffix: -code
target: build
- name: webapp
context: webapp
file: webapp/Dockerfile
target: production
suffix:
- name: maintenance
- name: maintenance-base
context: webapp
file: webapp/Dockerfile.maintenance
target: base
suffix: -base
- name: maintenance
- name: maintenance-build
context: webapp
file: webapp/Dockerfile.maintenance
target: code
suffix: -code
target: build
- name: maintenance
context: webapp
file: webapp/Dockerfile.maintenance
target: production
suffix:
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
Expand All @@ -82,13 +72,13 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=schedule,suffix=${{ matrix.app.suffix }}
type=semver,pattern={{version}},suffix=${{ matrix.app.suffix }}
type=semver,pattern={{major}}.{{minor}},suffix=${{ matrix.app.suffix }}
type=semver,pattern={{major}},suffix=${{ matrix.app.suffix }}
type=ref,event=branch,suffix=${{ matrix.app.suffix }}
type=ref,event=pr,suffix=${{ matrix.app.suffix }}
type=sha,suffix=${{ matrix.app.suffix }}
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Build and push Docker images
id: push
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75
Expand Down
42 changes: 7 additions & 35 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,24 @@
FROM node:20.12.1-alpine3.19 AS base

# ENVs
## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame
ENV DOCKER_WORKDIR="/app"
## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0
ARG BBUILD_DATE="1970-01-01T00:00:00.00Z"
ENV BUILD_DATE=$BBUILD_DATE
## We cannot do $(yarn run version)-${BUILD_NUMBER} here so we default to 0.0.0-0
ARG BBUILD_VERSION="0.0.0-0"
ENV BUILD_VERSION=$BBUILD_VERSION
## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000
ARG BBUILD_COMMIT="0000000"
ENV BUILD_COMMIT=$BBUILD_COMMIT
## SET NODE_ENV
ENV NODE_ENV="production"
## App relevant Envs
ENV PORT="4000"

# Labels
LABEL org.label-schema.build-date="${BUILD_DATE}"
LABEL org.label-schema.name="ocelot.social:backend"
LABEL org.label-schema.description="Backend of the Social Network Software ocelot.social"
LABEL org.label-schema.usage="https://github.com/Ocelot-Social-Community/Ocelot-Social/blob/master/README.md"
LABEL org.label-schema.url="https://ocelot.social"
LABEL org.label-schema.vcs-url="https://github.com/Ocelot-Social-Community/Ocelot-Social/tree/master/backend"
LABEL org.label-schema.vcs-ref="${BUILD_COMMIT}"
LABEL org.label-schema.vendor="ocelot.social Community"
LABEL org.label-schema.version="${BUILD_VERSION}"
LABEL org.label-schema.schema-version="1.0"
LABEL maintainer="[email protected]"

RUN apk --no-cache add git python3 make g++ bash

# Settings
## Expose Container Port
ENV NODE_ENV="production"
ENV PORT="4000"
EXPOSE ${PORT}

## Workdir
RUN mkdir -p ${DOCKER_WORKDIR}
WORKDIR ${DOCKER_WORKDIR}
RUN apk --no-cache add git python3 make g++ bash
RUN mkdir -p /app
WORKDIR /app
CMD ["/bin/bash", "-c", "yarn run start"]

FROM base AS development
CMD ["/bin/sh", "-c", "yarn install && yarn run dev"]

FROM base AS code
FROM base AS build
COPY . .
ONBUILD COPY ./branding/constants/ src/config/tmp
ONBUILD RUN tools/replace-constants.sh
Expand All @@ -57,9 +31,7 @@ ONBUILD RUN cp -r ./public /build/build
ONBUILD RUN cp -r ./package.json yarn.lock /build
ONBUILD RUN cd /build && yarn install --production=true --frozen-lockfile --non-interactive

FROM code AS build

FROM code AS test
FROM build AS test
CMD ["/bin/bash", "-c", "yarn run dev"]

FROM base AS production
Expand Down
47 changes: 7 additions & 40 deletions webapp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,24 @@
##################################################################################
# BASE (Is pushed to DockerHub for rebranding) ###################################
##################################################################################
FROM node:20.12.1-alpine3.19 AS base

# ENVs
## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame
ENV DOCKER_WORKDIR="/app"
## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0
ARG BBUILD_DATE="1970-01-01T00:00:00.00Z"
ENV BUILD_DATE=$BBUILD_DATE
## We cannot do $(yarn run version)-${BUILD_NUMBER} here so we default to 0.0.0-0
ARG BBUILD_VERSION="0.0.0-0"
ENV BUILD_VERSION=$BBUILD_VERSION
## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000
ARG BBUILD_COMMIT="0000000"
ENV BUILD_COMMIT=$BBUILD_COMMIT
## SET NODE_ENV
ENV NODE_ENV="production"
## App relevant Envs
ENV PORT="3000"

# Labels
LABEL org.label-schema.build-date="${BUILD_DATE}"
LABEL org.label-schema.name="ocelot.social:webapp"
LABEL org.label-schema.description="Web Frontend of the Social Network Software ocelot.social"
LABEL org.label-schema.usage="https://github.com/Ocelot-Social-Community/Ocelot-Social/blob/master/README.md"
LABEL org.label-schema.url="https://ocelot.social"
LABEL org.label-schema.vcs-url="https://github.com/Ocelot-Social-Community/Ocelot-Social/tree/master/webapp"
LABEL org.label-schema.vcs-ref="${BUILD_COMMIT}"
LABEL org.label-schema.vendor="ocelot.social Community"
LABEL org.label-schema.version="${BUILD_VERSION}"
LABEL org.label-schema.schema-version="1.0"
LABEL maintainer="[email protected]"

# Install Additional Software
## install: git
RUN apk --no-cache add git python3 make g++ bash jq

# Settings
## Expose Container Port
ENV NODE_ENV="production"
ENV PORT="3000"
EXPOSE ${PORT}

## Workdir
RUN mkdir -p ${DOCKER_WORKDIR}
WORKDIR ${DOCKER_WORKDIR}
RUN apk --no-cache add git python3 make g++ bash jq
RUN mkdir -p /app
WORKDIR /app
CMD ["/bin/bash", "-c", "yarn run start"]

FROM base AS development
CMD ["/bin/bash", "-c", "yarn install && yarn run dev"]

FROM base AS code
FROM base AS build
COPY . .
ONBUILD COPY ./branding .
ONBUILD RUN tools/merge-locales.sh
Expand All @@ -68,9 +37,7 @@ ONBUILD RUN cp -r ./locales /build
ONBUILD RUN cp -r ./package.json ./yarn.lock /build
ONBUILD RUN cd /build && yarn install --production=true --frozen-lockfile --non-interactive

FROM code AS build

FROM code AS test
FROM build AS test
CMD ["/bin/bash", "-c", "yarn run dev"]

FROM base AS production
Expand Down
33 changes: 7 additions & 26 deletions webapp/Dockerfile.maintenance
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
FROM node:20.12.1-alpine3.19 AS base
ENV DOCKER_WORKDIR="/app"
## We Cannot do `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` here so we use unix timestamp=0
ARG BBUILD_DATE="1970-01-01T00:00:00.00Z"
ENV BUILD_DATE=$BBUILD_DATE
## We cannot do $(yarn run version)-${BUILD_NUMBER} here so we default to 0.0.0-0
ARG BBUILD_VERSION="0.0.0-0"
ENV BUILD_VERSION=$BBUILD_VERSION
## We cannot do `$(git rev-parse --short HEAD)` here so we default to 0000000
ARG BBUILD_COMMIT="0000000"
ENV BUILD_COMMIT=$BBUILD_COMMIT
## SET NODE_ENV
ENV NODE_ENV="production"
## App relevant Envs
ENV PORT="3000"
LABEL org.label-schema.build-date="${BUILD_DATE}"
FROM nginx:alpine AS base
LABEL org.label-schema.name="ocelot.social:maintenance"
LABEL org.label-schema.description="Maintenance page of the Social Network Software ocelot.social"
LABEL org.label-schema.usage="https://github.com/Ocelot-Social-Community/Ocelot-Social/blob/master/README.md"
LABEL org.label-schema.url="https://ocelot.social"
LABEL org.label-schema.vcs-url="https://github.com/Ocelot-Social-Community/Ocelot-Social/tree/master/webapp"
LABEL org.label-schema.vcs-ref="${BUILD_COMMIT}"
LABEL org.label-schema.vendor="ocelot.social Community"
LABEL org.label-schema.version="${BUILD_VERSION}"
LABEL org.label-schema.schema-version="1.0"
LABEL maintainer="[email protected]"
RUN apk --no-cache add git python3 make g++ bash jq
EXPOSE ${PORT}
RUN mkdir -p ${DOCKER_WORKDIR}
WORKDIR ${DOCKER_WORKDIR}

FROM base AS code
FROM node:20.12.1-alpine3.19 AS build
ENV NODE_ENV="production"
RUN apk --no-cache add git python3 make g++ bash jq
RUN mkdir -p /app
WORKDIR /app
COPY assets assets
COPY components/LocaleSwitch/ components/LocaleSwitch
COPY components/Dropdown.vue components/Dropdown.vue
Expand All @@ -51,8 +34,6 @@ ONBUILD RUN yarn install --production=false --frozen-lockfile --non-interactive
ONBUILD RUN cp -r maintenance/source/* ./
ONBUILD RUN yarn run generate

FROM code as build

FROM nginx:alpine AS production
FROM build as production
COPY --from=build ./app/dist/ /usr/share/nginx/html/
COPY --from=build ./app/maintenance/nginx/custom.conf /etc/nginx/conf.d/default.conf

0 comments on commit 86993ce

Please sign in to comment.