-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathContainerfile
More file actions
115 lines (85 loc) · 3.81 KB
/
Containerfile
File metadata and controls
115 lines (85 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# syntax=docker/dockerfile:1.4
##
## Licensed to the Apache Software Foundation (ASF) under one
## or more contributor license agreements. See the NOTICE file
## distributed with this work for additional information
## regarding copyright ownership. The ASF licenses this file
## to you under the Apache License, Version 2.0 (the
## "License"); you may not use this file except in compliance
## with the License. You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing,
## software distributed under the License is distributed on an
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
## KIND, either express or implied. See the License for the
## specific language governing permissions and limitations
## under the License.
##
# Stage 1: Base image with package manager
FROM registry.access.redhat.com/ubi10/ubi-minimal:latest AS base
RUN microdnf -y install nodejs && \
microdnf clean all && \
npm install -g corepack && \
corepack enable && \
corepack prepare pnpm@latest --activate
# Set working directory for the monorepo
WORKDIR /monorepo
# Stage 2: Install all dependencies
FROM base AS dependencies
# Copy workspace configuration first
# These files change less frequently than source code
COPY pnpm-workspace.yaml ./
COPY package.json pnpm-lock.yaml ./
# Copy all package.json files from modules and components
# We only need the manifests, not the source code
COPY modules/package.json ./modules/
COPY components/management-controller/package.json ./components/management-controller/
COPY components/site-controller/package.json ./components/site-controller/
# Install all dependencies with build cache
# --frozen-lockfile ensures reproducible builds
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \
pnpm install --frozen-lockfile
# Stage 3: Build shared packages
FROM dependencies AS shared-builder
# Copy source code for shared packages only
COPY modules/ ./modules/
FROM shared-builder AS management-controller-deploy
COPY components/management-controller/ ./components/management-controller/
COPY console/ ./components/vms-web-app/
# Deploy creates a standalone directory with all dependencies
RUN pnpm --filter "@skupperx/management-controller" deploy --legacy --prod /deployed/management-controller
# Build the web app
RUN cd components/vms-web-app && npm install && npm run build && cp -r ./build /deployed/vms-web-app
# Production image - management-controller
FROM registry.access.redhat.com/ubi10/ubi-minimal:latest AS vms-management-controller
RUN microdnf -y install nodejs shadow-utils && \
microdnf clean all
WORKDIR /app
# Copy the entire deployed package
COPY --from=management-controller-deploy /deployed/management-controller ./
# Copy vms-web-app as sibling to /app (code expects ../vms-web-app)
COPY --from=management-controller-deploy /deployed/vms-web-app ./vms-web-app
RUN useradd --uid 10000 runner
USER 10000
EXPOSE 8085
CMD ["node", "index.js"]
FROM shared-builder AS site-controller-deploy
COPY components/site-controller/ ./components/site-controller/
# Deploy creates a standalone directory with all dependencies
RUN pnpm --filter "@skupperx/site-controller" deploy --legacy --prod /deployed/site-controller
# Production image - site-controller
FROM registry.access.redhat.com/ubi10/ubi-minimal:latest AS vms-site-controller
RUN microdnf -y install nodejs shadow-utils jq && \
microdnf clean all
WORKDIR /app
# Copy the entire deployed package
COPY --from=site-controller-deploy /deployed/site-controller ./
# Copy scripts to /usr/local/bin so they can be run as commands
COPY --from=site-controller-deploy /monorepo/components/site-controller/scripts/ /usr/local/bin/
RUN chmod +x /usr/local/bin/*
RUN useradd --uid 10000 runner
USER 10000
EXPOSE 8085
CMD ["node", "index.js"]