-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
146 lines (125 loc) 路 3.98 KB
/
Copy pathDockerfile
File metadata and controls
146 lines (125 loc) 路 3.98 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
FROM debian:12-slim AS build
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
jq \
openssl \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
curl \
libncursesw5-dev \
xz-utils \
tk-dev \
libxml2-dev \
libxmlsec1-dev \
libffi-dev \
liblzma-dev
WORKDIR /app
# Install mise and toolchains using repo versions in mise.toml
ENV PYTHONUNBUFFERED=1
ENV MISE_YES=1
ENV MISE_HTTP_TIMEOUT=120
ENV MISE_PYTHON_GITHUB_ATTESTATIONS=false
ENV PATH=/root/.local/bin:/root/.local/share/mise/shims:$PATH
RUN curl -fsSL https://mise.run | sh
COPY mise.toml ./
RUN mise trust && mise install
# Enable Corepack; Yarn version is selected via package.json "packageManager"
ENV COREPACK_ROOT=/root/.corepack
ENV PATH=$COREPACK_ROOT:$PATH
RUN mkdir -p $COREPACK_ROOT && \
mise exec node -- corepack enable --install-directory $COREPACK_ROOT
WORKDIR /app
COPY yarn.lock package.json ./
COPY backstage.json ./
COPY packages/backend/package.json ./packages/backend/package.json
COPY packages/app/package.json ./packages/app/package.json
COPY packages/backstage-theme-github/package.json ./packages/backstage-theme-github/package.json
COPY plugins/ plugins/
COPY .yarnrc.yml ./
COPY .yarn/plugins/ .yarn/plugins/
COPY backstage.json ./
RUN yarn install --immutable
COPY tsconfig.json ./
COPY lerna.json ./
COPY packages/ packages/
COPY plugins/ plugins/
COPY app-config.yaml ./
RUN yarn build:backend
FROM debian:12-slim AS run
# Install dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
jq \
unzip \
openssl \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
curl \
libncursesw5-dev \
xz-utils \
tk-dev \
libxml2-dev \
libxmlsec1-dev \
libffi-dev \
liblzma-dev
WORKDIR /app
# Install mise and toolchains using repo versions in mise.toml
ENV PYTHONUNBUFFERED=1
ENV MISE_YES=1
ENV MISE_HTTP_TIMEOUT=120
ENV MISE_PYTHON_GITHUB_ATTESTATIONS=false
ENV PATH=/root/.local/bin:/root/.local/share/mise/shims:$PATH
RUN curl -fsSL https://mise.run | sh
COPY mise.toml ./
RUN mise trust && mise install
# Enable Corepack; Yarn version is selected via package.json "packageManager"
ENV COREPACK_ROOT=/root/.corepack
ENV PATH=$COREPACK_ROOT:$PATH
RUN mkdir -p $COREPACK_ROOT && \
mise exec node -- corepack enable --install-directory $COREPACK_ROOT
WORKDIR /app
ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=1000 --no-node-snapshot"
# Copy repo skeleton first, to avoid unnecessary docker cache invalidation.
# The skeleton contains the package.json of each package in the monorepo,
# and along with yarn.lock and the root package.json, that's enough to run yarn install.
COPY yarn.lock ./
COPY package.json ./
COPY backstage.json ./
COPY --from=build /app/packages/backend/dist/skeleton.tar.gz ./
RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz
COPY .yarnrc.yml ./
COPY .yarn/plugins/ .yarn/plugins/
COPY backstage.json ./
RUN yarn workspaces focus --all --production && rm -rf "$(yarn cache clean)"
# Then copy the rest of the backend bundle, along with any other files we might want.
COPY --from=build /app/packages/backend/dist/bundle.tar.gz app-config*.yaml ./
RUN tar xzf bundle.tar.gz && rm bundle.tar.gz
# Copy any other files that we need at runtime
COPY app-config.yaml app-config.production.yaml ./
COPY examples/ examples/
# Cleanup
RUN rm -rf /var/lib/apt/lists/* \
/tmp/* \
/var/tmp/*
EXPOSE 7007
LABEL org.opencontainers.image.source="https://github.com/echohello-dev/backstage"
LABEL org.opencontainers.image.description="Backstage is an open platform for building developer portals."
WORKDIR /app/packages/backend
CMD ["node", ".", "--config", "../../app-config.yaml", "--config", "../../app-config.production.yaml"]