Skip to content
This repository was archived by the owner on Feb 4, 2026. It is now read-only.

Commit 4f1b743

Browse files
committed
add dockerfile for basic build env ci
1 parent 2ce5673 commit 4f1b743

File tree

2 files changed

+166
-0
lines changed

2 files changed

+166
-0
lines changed

.github/workflows/build.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Basic Env Docker Build and Publish
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
workflow_run:
7+
workflows: [ "build" ]
8+
branches: [ "master" ]
9+
types: [ "completed" ]
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: openxiangshan/xspdb
14+
IMAGE_TAG: ${{ github.sha }}
15+
16+
jobs:
17+
build-and-push-base:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v2
29+
30+
- name: Log in to GitHub Container Registry
31+
uses: docker/login-action@v2
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Build and push Docker image
38+
uses: docker/build-push-action@v4
39+
with:
40+
context: .
41+
file: ./docker/Dockerfile.buildenv
42+
platforms: linux/amd64
43+
push: true
44+
tags: |
45+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-${{ env.IMAGE_TAG }}
46+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-latest
47+
cache-from: type=local,src=/tmp/.buildx-cache
48+
cache-to: type=local,dest=/tmp/.buildx-cache

docker/Dockerfile.buildenv

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Use Ubuntu 24.04 as the base image
2+
FROM ghcr.io/openxiangshan/xs-env:ubuntu-24.04
3+
4+
# Set non-interactive installation
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Set the locale
8+
ENV LANG=C.UTF-8
9+
ENV LANGUAGE=C.UTF-8
10+
ENV LC_ALL=C.UTF-8
11+
# Use https for apt repositories
12+
RUN apt update && \
13+
apt install -y --no-install-recommends apt-transport-https ca-certificates && \
14+
apt-get clean && \
15+
rm -rf /var/lib/apt/lists/*
16+
RUN sed -i 's|http|https|g' /etc/apt/sources.list
17+
18+
# Set the timezone to France
19+
ENV TZ=Asia/Shanghai
20+
RUN apt-get update && \
21+
apt-get install -y --no-install-recommends tzdata && \
22+
ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
23+
dpkg-reconfigure --frontend noninteractive tzdata && \
24+
apt-get clean && \
25+
rm -rf /var/lib/apt/lists/*
26+
27+
# Install dependencies
28+
RUN apt-get update && apt-get install -y --no-install-recommends \
29+
ca-certificates \
30+
build-essential \
31+
git \
32+
sudo \
33+
wget \
34+
curl \
35+
vim \
36+
software-properties-common \
37+
python3 \
38+
python3-pip \
39+
python3-dev \
40+
libpcre3-dev \
41+
pkg-config \
42+
libfl-dev \
43+
bison \
44+
flex \
45+
gperf \
46+
clang \
47+
g++ \
48+
zlib1g-dev \
49+
openssh-server \
50+
gnupg \
51+
autoconf \
52+
automake \
53+
libtool \
54+
openjdk-17-jdk \
55+
libpcre2-dev \
56+
help2man && \
57+
apt-get clean && \
58+
rm -rf /var/lib/apt/lists/*
59+
60+
# Install SWIG (4.2.1)d
61+
RUN git clone https://github.com/swig/swig.git -b v4.2.1 --depth=1 /tmp/swig && \
62+
cd /tmp/swig && \
63+
./autogen.sh && \
64+
./configure --prefix=/usr/local && \
65+
make -j$(nproc) && \
66+
make install && \
67+
rm -rf /tmp/swig
68+
69+
# Set up Kitware repository and install the latest CMake
70+
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | \
71+
gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null && \
72+
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | \
73+
tee /etc/apt/sources.list.d/kitware.list >/dev/null && \
74+
apt-get update && \
75+
apt-get install -y --no-install-recommends cmake && \
76+
apt-get clean && \
77+
rm -rf /var/lib/apt/lists/*
78+
79+
# Verify Dependency installations
80+
RUN swig -version && \
81+
cmake --version && \
82+
verilator --version && \
83+
java --version && \
84+
python3 --version
85+
86+
# Install Picker
87+
ENV BUILD_XSPCOMM_SWIG=python,java
88+
RUN mkdir /workspace && \
89+
cd /workspace && \
90+
git clone https://github.com/XS-MLVP/picker.git --depth=1 && \
91+
wget https://github.com/chipsalliance/verible/releases/download/v0.0-3979-g786edf03/verible-v0.0-3979-g786edf03-linux-static-x86_64.tar.gz && \
92+
tar -xzf verible-v0.0-3979-g786edf03-linux-static-x86_64.tar.gz -C /usr/local/ --strip-components=1 && \
93+
rm verible-v0.0-3979-g786edf03-linux-static-x86_64.tar.gz && \
94+
cd picker && make init && \
95+
make -j$(nproc) && \
96+
make install && \
97+
make clean && \
98+
chmod 755 /usr/local/bin -R
99+
100+
# Get XS-Pdb
101+
RUN cd /workspace && \
102+
git clone https://github.com/OpenXiangShan/XSPdb.git --depth=1 && \
103+
cd XSPdb
104+
105+
# set user and password
106+
RUN useradd -m -s /bin/bash user && \
107+
echo "user:user" | chpasswd && \
108+
adduser user sudo && \
109+
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
110+
chown user:user -R /workspace && \
111+
chmod 755 /workspace
112+
113+
# Switch to the new user
114+
USER user
115+
# Set the default shell to bash
116+
SHELL ["/bin/bash", "-c"]
117+
# Set working directory
118+
WORKDIR /workspace

0 commit comments

Comments
 (0)