mirror of
https://github.com/louislam/dockge.git
synced 2024-11-25 09:43:25 +01:00
Change to download-docker-compose.ts
This commit is contained in:
parent
3c137122b6
commit
7581e61153
@ -2,6 +2,14 @@
|
||||
FROM node:18.17.1-bookworm-slim
|
||||
ENV PNPM_HOME="/pnpm"
|
||||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
|
||||
|
||||
# TARGETPLATFORM: linux/amd64, linux/arm64, linux/arm/v7
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
# TARGETARCH: amd64, arm64, arm/v7
|
||||
ARG TARGETARCH
|
||||
|
||||
RUN apt update && apt install --yes --no-install-recommends \
|
||||
curl \
|
||||
ca-certificates \
|
||||
@ -22,3 +30,9 @@ RUN apt update && apt install --yes --no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& npm install pnpm -g \
|
||||
&& pnpm install -g tsx
|
||||
|
||||
# Download docker-compose, as the repo's docker-compose is not up-to-date.
|
||||
COPY ./extra/download-docker-compose.ts ./extra/download-docker-compose.ts
|
||||
ARG DOCKER_COMPOSE_VERSION="2.23.3"
|
||||
RUN tsx ./extra/download-docker-compose.ts ${TARGETPLATFORM} ${DOCKER_COMPOSE_VERSION} \
|
||||
&& docker compose version
|
||||
|
39
extra/download-docker-compose.ts
Normal file
39
extra/download-docker-compose.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import fs from "fs";
|
||||
|
||||
async function main() {
|
||||
// TARGETPLATFORM
|
||||
const targetPlatform = process.argv[2];
|
||||
|
||||
// Docker Compose version
|
||||
const dockerComposeVersion = process.argv[3];
|
||||
|
||||
// Arch
|
||||
let arch = "";
|
||||
|
||||
if (targetPlatform === "linux/amd64") {
|
||||
arch = "x86_64";
|
||||
} else if (targetPlatform === "linux/arm64") {
|
||||
arch = "aarch64";
|
||||
} else if (targetPlatform === "linux/arm/v7") {
|
||||
arch = "armv7";
|
||||
} else {
|
||||
throw new Error(`Unknown target platform: ${targetPlatform}`);
|
||||
}
|
||||
|
||||
// mkdir -p /root/.docker/cli-plugins
|
||||
fs.mkdirSync("/root/.docker/cli-plugins", { recursive: true });
|
||||
|
||||
// Download URL
|
||||
const url = `https://github.com/docker/compose/releases/download/v${dockerComposeVersion}/docker-compose-linux-${arch}`;
|
||||
|
||||
console.log(url);
|
||||
|
||||
// Download docker-compose using fetch api, to "/root/.docker/cli-plugins/docker-compose"
|
||||
const buffer = await (await fetch(url)).arrayBuffer();
|
||||
fs.writeFileSync("/root/.docker/cli-plugins/docker-compose", Buffer.from(buffer));
|
||||
|
||||
// chmod +x /root/.docker/cli-plugins/docker-compose
|
||||
fs.chmodSync("/root/.docker/cli-plugins/docker-compose", 0o111);
|
||||
}
|
||||
|
||||
main();
|
Loading…
Reference in New Issue
Block a user