Skip to content

Commit 5ff86b6

Browse files
authored
Dockerfile: add tsffs-dev target (#169)
1 parent 8283e0c commit 5ff86b6

File tree

4 files changed

+106
-5
lines changed

4 files changed

+106
-5
lines changed

.devcontainer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"build": {
3+
"dockerfile": "Dockerfile",
4+
"target": "tsffs-dev"
5+
},
6+
"remoteUser": "vscode",
7+
"updateRemoteUserUID": true,
8+
"runArgs": [
9+
"--group-add",
10+
"dev"
11+
],
12+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/tsffs,type=bind",
13+
"workspaceFolder": "/workspace/tsffs",
14+
"customizations": {
15+
"vscode": {
16+
"extensions": [
17+
"rust-lang.rust-analyzer",
18+
"tamasfe.even-better-toml",
19+
"ms-azuretools.vscode-containers"
20+
]
21+
}
22+
}
23+
}

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
**/target/
44
**/*.img
55
**/*.diff.craff
6+
.devcontainer.json
67
# Don't add scripts so that builds dont have to rerun on script changes to those builds
78
scripts
8-
target
9+
target
10+
packages

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,3 +683,33 @@ jobs:
683683
with:
684684
name: simics-pkg-31337-linux64
685685
path: packages/simics-pkg-31337-*-linux64.ispm
686+
687+
check_docker_image:
688+
name: Check Docker Image
689+
runs-on: ubuntu-latest
690+
strategy:
691+
matrix:
692+
target: [tsffs-dev, tsffs-prod]
693+
steps:
694+
- name: Harden Runner
695+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
696+
with:
697+
egress-policy: audit
698+
699+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
700+
with:
701+
fetch-depth: 0
702+
lfs: false
703+
704+
- name: Set up Docker Buildx
705+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
706+
707+
- name: Build ${{ matrix.target }} target
708+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
709+
with:
710+
context: .
711+
target: ${{ matrix.target }}
712+
push: false
713+
tags: tsffs:${{ matrix.target }}
714+
cache-from: type=gha
715+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# SPDX-License-Identifier: Apache-2.0
33
# hadolint global ignore=DL3041,DL3040
44

5-
FROM fedora:42@sha256:ee88ab8a5c8bf78687ddcecadf824767e845adc19d8cdedb56f48521eb162b43
5+
FROM fedora:42@sha256:ee88ab8a5c8bf78687ddcecadf824767e845adc19d8cdedb56f48521eb162b43 AS tsffs-base
66

77
# Download links can be obtained from:
88
# https://lemcenter.intel.com/productDownload/?Product=256660e5-a404-4390-b436-f64324d94959
9-
ENV PUBLIC_SIMICS_PKGS_URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ead79ef5-28b5-48c7-8d1f-3cde7760798f/simics-6-packages-2024-05-linux64.ispm"
10-
ENV PUBLIC_SIMICS_ISPM_URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ead79ef5-28b5-48c7-8d1f-3cde7760798f/intel-simics-package-manager-1.8.3-linux64.tar.gz"
11-
ENV PUBLIC_SIMICS_PACKAGE_VERSION_1000="6.0.185"
9+
ARG PUBLIC_SIMICS_PKGS_URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ead79ef5-28b5-48c7-8d1f-3cde7760798f/simics-6-packages-2024-05-linux64.ispm"
10+
ARG PUBLIC_SIMICS_ISPM_URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/ead79ef5-28b5-48c7-8d1f-3cde7760798f/intel-simics-package-manager-1.8.3-linux64.tar.gz"
11+
ARG PUBLIC_SIMICS_PACKAGE_VERSION_1000="6.0.185"
1212
ENV SIMICS_BASE="/workspace/simics/simics-${PUBLIC_SIMICS_PACKAGE_VERSION_1000}/"
1313
# Add cargo and ispm to the path
1414
ENV PATH="/root/.cargo/bin:/workspace/simics/ispm:${PATH}"
@@ -124,3 +124,49 @@ RUN ispm projects /workspace/projects/example/ --create \
124124
ninja
125125

126126
RUN echo 'echo "To run the demo, run ./simics -no-gui --no-win fuzz.simics"' >> /root/.bashrc
127+
128+
FROM tsffs-base AS tsffs-dev
129+
ARG USER_UID=1000
130+
ARG USERNAME=vscode
131+
132+
# To build and run the dev image:
133+
# docker build --build-arg USER_UID=$(id -u) --target tsffs-dev -t tsffs:dev .
134+
# docker run --rm -ti -v .:/workspace/tsffs tsffs:dev
135+
136+
# hadolint ignore=DL3004,SC3009
137+
RUN <<EOF
138+
set -e
139+
# create group for developers
140+
groupadd dev
141+
# Create group and user with a home at /home/vscode
142+
useradd \
143+
--create-home \
144+
--uid $USER_UID \
145+
--user-group \
146+
--groups dev \
147+
--shell /bin/bash \
148+
$USERNAME \
149+
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME
150+
151+
# set /workspace/simics permissions to root:dev
152+
chown -R root:dev /workspace/{simics,projects} && chmod -R g+w /workspace/{simics,projects}
153+
154+
# install Rust nightly for the user
155+
sudo -E -u $USERNAME bash -c 'curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain none'
156+
157+
# copy Simics ISPM config
158+
mkdir -p /home/$USERNAME/.config
159+
cp -r "/root/.config/Intel Simics Package Manager/" "/home/$USERNAME/.config/"
160+
chown -R $USERNAME:$USERNAME "/home/$USERNAME/.config/"
161+
EOF
162+
163+
WORKDIR /workspace/tsffs
164+
165+
FROM fedora:42@sha256:ee88ab8a5c8bf78687ddcecadf824767e845adc19d8cdedb56f48521eb162b43 AS tsffs-prod
166+
167+
COPY --from=tsffs-base /workspace/projects /workspace/projects
168+
COPY --from=tsffs-base /workspace/simics /workspace/simics
169+
COPY --from=tsffs-base /root/.bashrc /root/.bashrc
170+
COPY --from=tsffs-base /root/.cargo /root/.cargo
171+
172+
WORKDIR /workspace/projects/example

0 commit comments

Comments
 (0)