Skip to content

Commit

Permalink
chore: Unify dockerfiles (#3404)
Browse files Browse the repository at this point in the history
* Unify dockerfiles

* fix setup busola

* cleanup

* empty

* unify names of images

* fix script

* unify names

* unify names

* use web name and bump image in chart

* fix naming
  • Loading branch information
dbadura authored Oct 15, 2024
1 parent 06831d0 commit 9b97e2d
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 204 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/setup-busola.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
export KYMA_DASHBOARD_IMG="k3d-registry.localhost:5000/kyma-dashboard"

echo "Build local image"
docker build -t "${KYMA_DASHBOARD_IMG}" -f Dockerfile.local.kyma .
docker build -t "${KYMA_DASHBOARD_IMG}" -f Dockerfile .
echo "Running kyma-dashboard... with ${ENV} configuration"
docker run -d --rm --net=host --pid=host --name kyma-dashboard --env ENVIRONMENT="${ENV}" "${KYMA_DASHBOARD_IMG}"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
name: Busola Local Build
name: Busola Build

on:
push:
branches:
- main
paths:
- ".github/workflows/busola-local-build.yml"
- ".github/workflows/busola-build.yml"
- "backend/**"
- "kyma/**"
- "public/**"
- "src/**"
- "tests/**"
- "package.json"
- "Makefile"
- "Dockerfile.local"
- "Dockerfile"
pull_request_target:
types: [opened, edited, synchronize, reopened, ready_for_review]
paths:
- ".github/workflows/busola-local-build.yml"
- ".github/workflows/busola-build.yml"
- "kyma/**"
- "backend/**"
- "public/**"
- "src/**"
- "tests/**"
- "package.json"
- "Makefile"
- "Dockerfile.local"
- "Dockerfile"

permissions:
id-token: write # This is required for requesting the JWT token
contents: read # This is required for actions/checkout

jobs:
build-local-image:
build-busola-image:
uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main # Usage: kyma-project/test-infra/.github/workflows/image-builder.yml@main
with:
name: busola
dockerfile: Dockerfile.local
dockerfile: Dockerfile
context: .
export-tags: true
tags: latest
50 changes: 0 additions & 50 deletions .github/workflows/busola-kyma-build.yml

This file was deleted.

8 changes: 5 additions & 3 deletions .github/workflows/busola-web-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ on:
- main
paths:
- ".github/workflows/busola-web-build.yml"
- "kyma/**"
- "public/**"
- "src/**"
- "package.json"
- "Makefile"
- "Dockerfile"
- "Dockerfile.web"
pull_request_target:
types: [opened, edited, synchronize, reopened, ready_for_review]
paths:
- ".github/workflows/busola-web-build.yml"
- "kyma/**"
- "public/**"
- "src/**"
- "package.json"
- "Makefile"
- "Dockerfile"
- "Dockerfile.web"

permissions:
id-token: write # This is required for requesting the JWT token
Expand All @@ -30,7 +32,7 @@ jobs:
uses: kyma-project/test-infra/.github/workflows/image-builder.yml@main # Usage: kyma-project/test-infra/.github/workflows/image-builder.yml@main
with:
name: busola-web
dockerfile: Dockerfile
dockerfile: Dockerfile.web
context: .
export-tags: true
tags: latest
55 changes: 40 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# this is a Dockerfile for single deployment app - both backend and frontends

# ---- Base Alpine with Node ----
FROM node:20.17-alpine3.20 AS builder
FROM node:20.17-alpine3.20 AS builder
ARG default_tag

# Install global dependencies
RUN apk update && \
apk upgrade && \
apk add --no-cache make yq

WORKDIR /app

# Install global dependencies

# Set env variables
ENV PRODUCTION true
ENV CI true
Expand All @@ -19,24 +22,46 @@ RUN yq -i '.version = "'${default_tag}'"' public/version.yaml && \
make resolve validate

RUN npm run build:docker
RUN cd /app/backend && npm run build

# ---- Environments Configuration ----
FROM node:20.17-alpine3.20 AS configuration
WORKDIR /kyma

RUN apk add make

#Copy /kyma configuration into container to /kyma
COPY /kyma /kyma

RUN npm ci
RUN make prepare-configuration

# ---- Serve ----
FROM nginxinc/nginx-unprivileged:1.27.1-alpine3.20
FROM alpine:3.20.2
WORKDIR /app

# apps
COPY --from=builder /app/build /app/core-ui
RUN apk --no-cache upgrade && \
apk --no-cache --update add nginx nodejs npm yq
WORKDIR /app

COPY --chown=65532:65532 --from=builder /app/build /app/core-ui
COPY --chown=65532:65532 --from=builder /app/backend/backend-production.js /app/backend-production.js
COPY --chown=65532:65532 --from=builder /app/backend/certs.pem /app/certs.pem
COPY --chown=65532:65532 --from=builder /app/backend/package* /app/
COPY --chown=65532:65532 --from=builder /app/backend/settings/* /app/settings/
COPY --chown=65532:65532 --from=builder /app/start_node.sh /app/start_node.sh
COPY --chown=65532:65532 --from=configuration /kyma/build /app/core-ui/environments

RUN npm ci --only=production

# nginx
COPY --from=builder /app/nginx/nginx.conf /etc/nginx/
COPY --from=builder /app/nginx/mime.types /etc/nginx/
# use sessionStorage as default
# SHOW_KYMA_VERSION for production
RUN yq eval -i '.config.features.SHOW_KYMA_VERSION.isEnabled = true' core-ui/defaultConfig.yaml
RUN yq eval -i '.config.defaultStorage = "sessionStorage"' core-ui/defaultConfig.yaml

#entrypoint
COPY --from=builder --chown=nginx /app/start_nginx.sh /app/start_nginx.sh
USER 65532:65532

USER root:root
RUN chown -R nginx:root /etc/nginx /app/core-ui
USER nginx:nginx
EXPOSE 3001
ENV NODE_ENV=production ADDRESS=0.0.0.0 IS_DOCKER=true ENVIRONMENT=""

EXPOSE 8080
ENTRYPOINT ["/app/start_nginx.sh"]
ENTRYPOINT ["/app/start_node.sh"]
55 changes: 0 additions & 55 deletions Dockerfile.local

This file was deleted.

68 changes: 0 additions & 68 deletions Dockerfile.local.kyma

This file was deleted.

1 change: 0 additions & 1 deletion Dockerfile.kyma → Dockerfile.web
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ RUN npm run build:docker

# ---- Environments Configuration ----
FROM node:20.17-alpine3.20 as configuration
#RUN apk add make
WORKDIR /kyma

RUN apk add make
Expand Down
2 changes: 1 addition & 1 deletion resources/base/web/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: busola
image: europe-docker.pkg.dev/kyma-project/prod/busola-kyma-web:latest
image: europe-docker.pkg.dev/kyma-project/prod/busola-web:latest
imagePullPolicy: Always
env:
- name: ENVIRONMENT
Expand Down
1 change: 0 additions & 1 deletion tests/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"test:cluster:local": "CYPRESS_LOCAL_DEV=true cypress run --spec \"tests/cluster/*.spec.js,tests/extensibility/*.spec.js\" --browser chrome",
"test:namespace": "cypress run --spec \"tests/namespace/*.spec.js\" --browser chromium",
"test:namespace:local": "CYPRESS_LOCAL_DEV=true cypress run --spec \"tests/namespace/*.spec.js\" --browser chrome",
"test:accesibility": "cypress run --spec \"tests/accessibility/*.spec.js\" --browser chromium",
"test:kyma-e2e": "cypress run --spec \"tests/kyma*/*spec.js\" --browser chromium",
"test:kyma-e2e:local": "CYPRESS_LOCAL_DEV=true cypress run --spec \"tests/kyma*/*spec.js\" --browser chromium",
"test:smoke-extensions": "cypress run --browser chromium -C cypress-smoke.js",
Expand Down

0 comments on commit 9b97e2d

Please sign in to comment.