Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
ccee5e7257 | |||
8d361f7259 | |||
fa576b42c9 |
@ -1,93 +0,0 @@
|
||||
name: build-docker-images-for-multi-latest-release
|
||||
|
||||
#on:
|
||||
# push:
|
||||
# branches:
|
||||
# - main
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Checkout the repository
|
||||
- name: Checkout repository
|
||||
uses: http://fly6516.synology.me:4000/Gitea_Action/checkout@v2
|
||||
|
||||
# Pre-pull Ubuntu images and push to private registry
|
||||
- name: Pre-pull and Push Ubuntu Images
|
||||
run: |
|
||||
UBUNTU_VERSIONS=("18.04" "20.04" "22.04")
|
||||
for version in "${UBUNTU_VERSIONS[@]}"; do
|
||||
IMAGE_NAME="dockerp.com/ubuntu:$version"
|
||||
TARGET_NAME="fly6516.synology.me:8080/ubuntu:$version"
|
||||
|
||||
# Pull the image from Docker Hub if not already exists locally
|
||||
if ! docker image inspect "$IMAGE_NAME" > /dev/null 2>&1; then
|
||||
echo "Pulling $IMAGE_NAME from Docker Hub..."
|
||||
docker pull "$IMAGE_NAME"
|
||||
else
|
||||
echo "$IMAGE_NAME already exists locally."
|
||||
fi
|
||||
|
||||
# Tag and push to the private registry
|
||||
docker tag "$IMAGE_NAME" "$TARGET_NAME"
|
||||
docker push "$TARGET_NAME"
|
||||
done
|
||||
|
||||
# Pre-pull QEMU and Buildx images
|
||||
- name: Pre-pull QEMU and Buildx Images
|
||||
run: |
|
||||
# Define the images to pull
|
||||
QEMU_IMAGE="dockerp.com/multiarch/qemu-user-static:latest"
|
||||
BUILDX_IMAGE="dockerp.com/moby/buildkit:buildx-stable-1"
|
||||
|
||||
# Check and pull multiarch/qemu-user-static if not exists
|
||||
if ! docker image inspect "$QEMU_IMAGE" > /dev/null 2>&1; then
|
||||
echo "Pulling $QEMU_IMAGE..."
|
||||
docker pull "$QEMU_IMAGE"
|
||||
else
|
||||
echo "$QEMU_IMAGE already exists locally."
|
||||
fi
|
||||
|
||||
# Check and pull buildkit/buildx-stable-1 if not exists
|
||||
if ! docker image inspect "$BUILDX_IMAGE" > /dev/null 2>&1; then
|
||||
echo "Pulling $BUILDX_IMAGE..."
|
||||
docker pull "$BUILDX_IMAGE"
|
||||
else
|
||||
echo "$BUILDX_IMAGE already exists locally."
|
||||
fi
|
||||
|
||||
# Set up Docker Buildx
|
||||
- name: Set up Docker Buildx
|
||||
uses: http://fly6516.synology.me:4000/docker/setup-buildx-action@v2
|
||||
|
||||
# Log in to Gitea Docker Registry
|
||||
- name: Log in to Gitea Docker Registry
|
||||
uses: http://fly6516.synology.me:4000/docker/login-action@v2
|
||||
with:
|
||||
registry: https://fly6516.synology.me:8080
|
||||
username: ${{ secrets.DOCKER_SYN_USER }}
|
||||
password: ${{ secrets.DOCKER_SYN_PWD }}
|
||||
|
||||
# Set Docker Timeout
|
||||
- name: Set Docker Timeout
|
||||
run: |
|
||||
echo "DOCKER_CLIENT_TIMEOUT=300" >> $GITHUB_ENV
|
||||
echo "DOCKER_BUILD_TIMEOUT=300" >> $GITHUB_ENV
|
||||
|
||||
# Build and push the Docker image for all platforms (including multi-architecture support)
|
||||
- name: Build and Push Multi-Platform Docker Image
|
||||
uses: http://fly6516.synology.me:4000/docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
tags: fly6516.synology.me:8080/multilang:latest
|
||||
context: .
|
||||
file: ./Dockerfile # Ensure this points to the correct Dockerfile location
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
|
||||
# Optional: Verify the pushed image
|
||||
- name: Verify Docker Image
|
||||
run: |
|
||||
docker pull fly6516.synology.me:8080/multilang:latest
|
||||
docker run --rm fly6516.synology.me:8080/multilang:latest bash -c "echo 'Image verified'"
|
@ -1,53 +0,0 @@
|
||||
name: build-docker-images-for-latest-release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Checkout the repository
|
||||
- name: Checkout repository
|
||||
uses: http://fly6516.synology.me:4000/Gitea_Action/checkout@v2
|
||||
|
||||
# # Pre-pull image if needed
|
||||
# - name: Pre Pull Image if Needed
|
||||
# run: |
|
||||
# IMAGE_NAME="dockerp.com/moby/buildkit:buildx-stable-1"
|
||||
# if ! docker image inspect "$IMAGE_NAME" > /dev/null 2>&1; then
|
||||
# echo "Image does not exist locally. Pulling..."
|
||||
# docker pull "$IMAGE_NAME"
|
||||
# else
|
||||
# echo "Image already exists locally."
|
||||
# fi
|
||||
|
||||
# Log in to Gitea Docker Registry
|
||||
- name: Log in to Gitea Docker Registry
|
||||
run: |
|
||||
echo ${{ secrets.DOCKER_SYN_PWD }} | docker login https://fly6516.synology.me:8080 -u ${{ secrets.DOCKER_SYN_USER }} --password-stdin
|
||||
|
||||
# Set Docker Timeout
|
||||
- name: Set Docker Timeout
|
||||
run: |
|
||||
echo "DOCKER_CLIENT_TIMEOUT=300" >> $GITHUB_ENV
|
||||
echo "DOCKER_BUILD_TIMEOUT=300" >> $GITHUB_ENV
|
||||
|
||||
# Build the Docker image
|
||||
- name: Build Docker Image
|
||||
run: |
|
||||
docker build -t fly6516.synology.me:8080/multilang:latest .
|
||||
|
||||
# Push the Docker image
|
||||
- name: Push Docker Image
|
||||
run: |
|
||||
docker push fly6516.synology.me:8080/multilang:latest
|
||||
|
||||
# Optional: Verify the pushed image
|
||||
- name: Verify Docker Image
|
||||
run: |
|
||||
docker pull fly6516.synology.me:8080/multilang:latest
|
||||
docker run --rm fly6516.synology.me:8080/multilang:latest bash -c "echo 'Image verified'"
|
118
Dockerfile
118
Dockerfile
@ -1,62 +1,78 @@
|
||||
# LABEL authors="fly"
|
||||
# 第一阶段:构建阶段
|
||||
FROM dockerp.com/node:20-alpine AS builder
|
||||
|
||||
# ENTRYPOINT ["top", "-b"]
|
||||
|
||||
# 使用 Ubuntu 作为基础镜像
|
||||
FROM fly6516.synology.me:8080/ubuntu:20.04
|
||||
#FROM ubuntu:20.04
|
||||
|
||||
# 设置环境变量
|
||||
# 设置环境变量,避免交互式安装
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
## 安装 QEMU 模拟器,支持多架构构建
|
||||
#RUN apt-get update && apt-get install -y \
|
||||
# qemu-user-static \
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
# 使用南京大学的 apk 源并安装构建工具
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.nju.edu.cn/g' /etc/apk/repositories && \
|
||||
apk update && \
|
||||
apk add --no-cache \
|
||||
curl \
|
||||
# git>=2.18 \
|
||||
build-base \
|
||||
openjdk11 \
|
||||
python3 \
|
||||
py3-pip \
|
||||
grep \
|
||||
go \
|
||||
rust \
|
||||
ruby \
|
||||
php \
|
||||
ghc \
|
||||
perl \
|
||||
lua5.3 \
|
||||
&& \
|
||||
apk add --no-cache git \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
# 使用南京大学的 apt 源
|
||||
RUN sed -i 's/archive.ubuntu.com/mirrors.nju.edu.cn/g' /etc/apt/sources.list
|
||||
|
||||
# 更新系统并安装常用工具
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
wget \
|
||||
git \
|
||||
build-essential \
|
||||
software-properties-common \
|
||||
apt-transport-https \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 安装 Node.js(替换为南京大学的源)
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
||||
# sed -i 's|deb.nodesource.com|mirror.nju.edu.cn/nodesource/deb|g' /etc/apt/sources.list.d/nodesource.list && \
|
||||
apt-get update && apt-get install -y nodejs && npm config set registry https://repo.nju.edu.cn/repository/npm/ # 修改源
|
||||
|
||||
# 安装其他语言的编译器和工具
|
||||
RUN apt-get update && apt-get install -y \
|
||||
gcc g++ make \
|
||||
openjdk-11-jdk \
|
||||
python3 python3-pip \
|
||||
golang \
|
||||
rustc cargo \
|
||||
ruby-full \
|
||||
php composer \
|
||||
ghc cabal-install \
|
||||
perl \
|
||||
lua5.3 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 安装 .NET SDK
|
||||
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
|
||||
dpkg -i packages-microsoft-prod.deb && \
|
||||
apt-get update && apt-get install -y dotnet-sdk-6.0 && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
# 设置 npm 镜像源
|
||||
RUN npm config set registry https://repo.nju.edu.cn/repository/npm/
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /workspace
|
||||
|
||||
# 暴露端口(如有需要)
|
||||
#EXPOSE 3000
|
||||
# # 复制 package.json 和 package-lock.json
|
||||
# COPY package.json ./
|
||||
# # COPY package-lock.json ./
|
||||
|
||||
# # 安装 Node.js 依赖
|
||||
# RUN npm install
|
||||
|
||||
# 复制剩余的项目文件
|
||||
COPY . .
|
||||
|
||||
# 第二阶段:运行阶段(极限小)
|
||||
FROM dockerp.com/node:20-alpine
|
||||
|
||||
# 设置 npm 镜像源
|
||||
RUN npm config set registry https://repo.nju.edu.cn/repository/npm/
|
||||
|
||||
# 使用南京大学的 apk 源并安装运行时依赖
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.nju.edu.cn/g' /etc/apk/repositories && \
|
||||
apk update && \
|
||||
apk add --no-cache \
|
||||
curl \
|
||||
# git>=2.18 \
|
||||
openjdk11 \
|
||||
python3 \
|
||||
grep \
|
||||
go \
|
||||
rust \
|
||||
ruby \
|
||||
php \
|
||||
ghc \
|
||||
perl \
|
||||
lua5.3 \
|
||||
&& \
|
||||
apk add --no-cache git \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /workspace
|
||||
|
||||
# 从构建阶段复制必要文件
|
||||
COPY --from=builder /workspace /workspace
|
||||
|
||||
# 默认启动 Bash
|
||||
CMD ["bash"]
|
||||
|
118
README.md
118
README.md
@ -1,117 +1,3 @@
|
||||
# Multi-Lang
|
||||
|
||||
# Multi-Language Compile Environment / 多语言编译环境
|
||||
|
||||
[English Version](#english-version) | [中文版本](#中文版本)
|
||||
|
||||
---
|
||||
|
||||
## English Version
|
||||
<a id="english-version"></a>
|
||||
|
||||
> ❗️ **Warning** > The `slim` and `max` versions and their branches have been temporarily put on hold due to optimizations in the `latest` image (main branch). They may contain bugs and are not recommended for compiling or running images.
|
||||
|
||||
### Overview
|
||||
This project provides a Docker-based multi-language compile environment. It is designed to support development in various programming languages such as C/C++, Java, Python, Node.js, Go, Rust, Ruby, PHP, Haskell, Perl, Lua, and .NET.
|
||||
**[Docker Hub](https://hub.docker.com/r/fly6516/multilang)**
|
||||
- you can just use the prebuild images at multi-platform
|
||||
- ```bash
|
||||
docker pull fly6516/multilang
|
||||
```
|
||||
- you can use the pre-installed compilers and tools to compile and run your projects. The working directory is set to `/workspace`.
|
||||
|
||||
### Prerequisites
|
||||
- Docker (with Buildx support if needed)
|
||||
- Internet access to download dependencies
|
||||
|
||||
### Build Instructions
|
||||
1. **Build the Docker image:**
|
||||
Execute the following command in the project directory:
|
||||
```bash
|
||||
docker build -t multi-lang .
|
||||
```
|
||||
2. **Run the container:**
|
||||
Start a container with:
|
||||
```bash
|
||||
docker run -it --rm multi-lang
|
||||
```
|
||||
|
||||
### Usage
|
||||
Once inside the container, you can use the pre-installed compilers and tools to compile and run your projects. The working directory is set to `/workspace`.
|
||||
|
||||
### Building
|
||||
|
||||
#### create and enable Buildx builder
|
||||
```bash
|
||||
docker buildx create --use
|
||||
```
|
||||
|
||||
#### run QEMU to emulate multiplatform
|
||||
```bash
|
||||
docker run --rm --privileged fly6516.synology.me:8080/multiarch/qemu-user-static --reset -p yes
|
||||
```
|
||||
|
||||
#### build and push docker image
|
||||
```bash
|
||||
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x,linux/mips64le -t fly6516/multilang:latest . --push
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
[中文版本](#中文版本)
|
||||
|
||||
---
|
||||
|
||||
## 中文版本
|
||||
<a id="中文版本"></a>
|
||||
|
||||
> ❗️ **警告** > 由于 latest 镜像(即 main 分支)的优化,slim 和 max 版本及其分支已被暂时搁置,可能存在 Bug,不建议进行编译或运行镜像。
|
||||
|
||||
### 概述
|
||||
该项目构建了一个基于 Docker 的多语言编译环境,支持 C/C++、Java、Python、Node.js、Go、Rust、Ruby、PHP、Haskell、Perl、Lua 以及 .NET 等多种语言的开发和编译。
|
||||
**[Docker Hub](https://hub.docker.com/r/fly6516/multilang)**
|
||||
- 您可以在多平台下使用预构建的镜像。
|
||||
- ```bash
|
||||
docker pull fly6516/multilang
|
||||
```
|
||||
- 您可以使用预先安装的编译器和工具来编译和运行您的项目。工作目录设置为 `/workspace`。
|
||||
|
||||
### 前提条件
|
||||
- 安装 Docker(如果需要可支持 Buildx)
|
||||
- 具备下载依赖的网络环境
|
||||
|
||||
### 构建步骤
|
||||
1. **构建 Docker 镜像:**
|
||||
在项目目录下执行:
|
||||
```bash
|
||||
docker build -t multi-lang .
|
||||
```
|
||||
2. **运行容器:**
|
||||
使用以下命令启动容器:
|
||||
```bash
|
||||
docker run -it --rm multi-lang
|
||||
```
|
||||
|
||||
### 使用方法
|
||||
进入容器后,所有的编译器与工具已经预先安装好,工作目录为 `/workspace`,可以直接在此目录下进行项目的开发和编译。
|
||||
|
||||
|
||||
### 编译
|
||||
|
||||
#### 创建并启用 Buildx 构建器
|
||||
```bash
|
||||
docker buildx create --use
|
||||
```
|
||||
|
||||
#### 启动 QEMU 支持的多架构模拟器
|
||||
```bash
|
||||
docker run --rm --privileged fly6516.synology.me:8080/multiarch/qemu-user-static --reset -p yes
|
||||
```
|
||||
|
||||
#### 构建并推送多架构 Docker 镜像
|
||||
```bash
|
||||
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le,linux/s390x,linux/mips64le -t fly6516/multilang:latest . --push
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
[English Version](#english-version)
|
||||
multi-lang-dev
|
33
package.json
Normal file
33
package.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "multi-language-development-env",
|
||||
"version": "1.0.0",
|
||||
"description": "A Docker image for multi-language development environment with Node.js and other tools",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"test": "echo \"No tests specified\" && exit 0",
|
||||
"build": "echo \"Building project...\""
|
||||
},
|
||||
"keywords": [
|
||||
"docker",
|
||||
"nodejs",
|
||||
"multi-language",
|
||||
"development"
|
||||
],
|
||||
"author": "fly6516",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"express": "^4.17.1",
|
||||
"axios": "^0.21.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.7",
|
||||
"webpack": "^5.24.0",
|
||||
"webpack-cli": "^4.5.0",
|
||||
"babel-loader": "^8.2.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user