Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added wrapper dockerfile and updated linux readme #10

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .devcontainer/CentOS-Base.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra

Check failure on line 3 in .devcontainer/CentOS-Base.repo

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/

Check failure on line 4 in .devcontainer/CentOS-Base.repo

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace
gpgcheck=1

Check failure on line 5 in .devcontainer/CentOS-Base.repo

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace
enabled=0

Check failure on line 6 in .devcontainer/CentOS-Base.repo

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates

[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra

Check failure on line 13 in .devcontainer/CentOS-Base.repo

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/

Check failure on line 14 in .devcontainer/CentOS-Base.repo

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace
gpgcheck=1

Check failure on line 15 in .devcontainer/CentOS-Base.repo

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace
enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]
name=CentOS-$releasever - Extras

Check failure on line 21 in .devcontainer/CentOS-Base.repo

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra

Check failure on line 22 in .devcontainer/CentOS-Base.repo

View workflow job for this annotation

GitHub Actions / Checkpatch

ERROR:TRAILING_WHITESPACE: trailing whitespace
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

# Vault

[Vault-base]
name=Vault - CentOS-$releasever - Base
baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-$releasever

[Vault-updates]
name=Vault - CentOS-$releasever - Updates
baseurl=http://vault.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-$releasever

[Vault-extras]
name=Vault - CentOS-$releasever – Extras
baseurl=http://vault.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-$releasever
41 changes: 41 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM alpine:latest AS downloader

RUN apk add --no-cache wget tar

WORKDIR /sources

# get new mirror from https://www.openssh.com/portable.html should this one fail
RUN wget https://ftp.hostserver.de/pub/OpenBSD/OpenSSH/portable/openssh-9.9p1.tar.gz -O openssh.tar.gz && \
tar -xzvf openssh.tar.gz

FROM gitlab.cs.pub.ro:5050/ac/ac-public/vivado-slim:1.0.0


COPY ./CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo
RUN yum clean all
RUN yum makecache

RUN yum -y install xorg-x11-xauth


COPY --from=downloader /sources/openssh-9.9p1 /src/openssh-portable

WORKDIR /src/openssh-portable
RUN ./configure --without-openssl --without-zlib
RUN make install
COPY ./sshd_config /usr/local/etc/sshd_config

# modify this as you wish
RUN passwd root --delete

RUN useradd sshd

COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
RUN echo "cd /workspaces/computer-architecture" >> /root/.bashrc

WORKDIR /workspaces/computer-architecture
# uncomment if vivado shows blank screen
# RUN echo "export _JAVA_AWT_WM_NONREPARENTING=1" >> /root/.bashrc

CMD ["/entrypoint.sh"]
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "Vivado Slim Dev",
//"build": { "dockerfile": "Dockerfile" },
// "build": { "dockerfile": "Dockerfile" },
"image": "gitlab.cs.pub.ro:5050/ac/ac-public/vivado-slim:1.0.0",
"runArgs": [
"--rm",
"--privileged"
],
//"appPort": [3121, 60001, 3042],
// "appPort": "2222:22",
"mounts": ["type=bind,source=/dev,target=/dev"],
//"otherPortsAttributes": {"requireLocalPort": "true", "elevateIfNeeded" : "true"},
// "postStartCommand": "/usr/local/sbin/sshd",
"customizations": {
"vscode": {
"extensions": [
Expand Down
3 changes: 3 additions & 0 deletions .devcontainer/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
/usr/local/sbin/sshd
/bin/bash -l
116 changes: 116 additions & 0 deletions .devcontainer/sshd_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# $OpenBSD: sshd_config,v 1.104 2021/07/02 05:11:21 dtucker Exp $

# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
PermitEmptyPasswords yes
XAuthLocation /usr/bin/xauth
# Change to no to disable s/key passwords
#KbdInteractiveAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the KbdInteractiveAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via KbdInteractiveAuthentication may bypass
# the setting of "PermitRootLogin prohibit-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and KbdInteractiveAuthentication to 'no'.
#UsePAM no

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem sftp /usr/libexec/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# PermitTTY no
# ForceCommand cvs server
71 changes: 71 additions & 0 deletions chapters/guides/docker/linux/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Utilizare imagine docker Linux

## Cerințe necesare
1. Sa aveti VSCode instalat
2. Sa aveti un Desktop Environment sau un Window manager ce ruleaza cu X Server.
3. Sa aveti Docker CE instalat (Atentie, nu docker desktop! O sa trebuiasca privileged execution pentru a forwarda folderul /dev iar acesta face acest lucru foarte enervant si dificil)
- [Ubuntu/Fedora](https://docs.docker.com/engine/install/)
- Arch: ```sudo pacman -S docker```
* Daca aveti deja docker desktop instalat de pe AUR o sa va apara conflicte. Va apar frumos acolo pachetele conflictuale, e alegerea voastra what comes next.

## Rulare

Expand Down Expand Up @@ -31,3 +37,68 @@ docker run --rm -it -v /dev:/dev gitlab.cs.pub.ro:5050/ac/ac-public/vivado-slim:
```bash
vivado
```

## Troubleshooting
### Primesc eroare cand scriu in shell ```vivado```/nu apare GUI-ul
Inainte de a rula urmatoarele solutii, **asigurati-va inainte ca .devcontainer/{sshd_config,Dockerfile,devcontainer.json} respecta cerintele de securitate impuse de voi**. Urmatoarea metoda o sa expuna un port la ssh pe un container privilegiat neparolat care are expus /dev-ul vostru. Asigurati-va ca nu exista posibilitatea ca o masina remote sa se poata conecta la acel port al vostru, sau modificati sshd_config-ul astfel incat sa respecte cerintele de securitate, sau schimbati parola de root (in dockerfile)
#### Devcontainer fara GUI
Va trebui sa editati devcontainer.json (aveti comentate deja liniile necesare, decomentati image) ca sa va apara in felul acesta:
```json
{
"name": "Vivado Slim Dev",
"build": { "dockerfile": "Dockerfile" },
// "image": "gitlab.cs.pub.ro:5050/ac/ac-public/vivado-slim:1.0.0",
"runArgs": [
"--rm",
"--privileged"
],
"appPort": "2222:22",
"mounts": ["type=bind,source=/dev,target=/dev"],
//"otherPortsAttributes": {"requireLocalPort": "true", "elevateIfNeeded" : "true"},
"postStartCommand": "/usr/local/sbin/sshd",
"customizations": {
"vscode": {
"extensions": [
"mshr-h.veriloghdl"
]
}
}
}
```
Dupa apasati ```Ctrl+Shift+P``` si apasati pe ```Dev Containers: Rebuild and Reopen in Container```.

Pentru a putea accesa gui-ul deschideti un terminal (nu acela de pe vscode) si scrieti ```ssh -XY -p 2222 root@localhost```. Nu va trebui sa introduceti nicio parola. Puteti modifica portul cu ce doriti voi atata timp cat modificati acest lucru si in devcontainer.json la appPort.

#### Setup manual de docker fara GUI
In radacina proiectului computer-architecture executati
```
cd .devcontainer
docker build -t vivado-slim-sshx .
cd ..
docker run -it -v /dev:/dev -p 2222:22 -v $PWD:/workspaces/computer-architecture vivado-slim-sshx
```
### Am wayland. Ce fac?
Va trebui sa faci [pasul asta](#primesc-eroare-cand-scriu-in-shell-vivadonu-apare-gui-ul).

Exista 2 optiuni rapide:
1. Instaleaza Xwayland si urmeaza setup-ul/configurarea pentru DE-ul/WM-ul tau
2. Instaleaxa Xephyr si foloseste comanda aceasta: ```Xephyr -br -ac -noreset -screen 1920x1080 :1```. Inlocuieste 1920x1080 cu rezolutia folosita de tine, o sa se deschida o fereastra. Dupa scrii ```DISPLAY=:1 ssh -X -p 2222 root@localhost```. Gui-ul de la vivado va aparea in fereastra de tocmai s-a deschis

Mai multe detalii [aici](https://www.dbts-analytics.com/notesxfwdgb.html)

### Am ecran alb cand deschid cu wayland
scrie in shell inainte sa executi vivado ```export _JAVA_AWT_WM_NONREPARENTING=1```. Sau decomenteaza linia din Dockerfile care da echo la aceasta linie in .bashrc

### Stuck la deschiderea hardware managerului
In terminalul din vscode scrie ```hw_server```, daca o sa functioneze o sa apare cv gen
```
****** Xilinx hw_server v2022.1
**** Build date : Apr 18 2022 at 16:10:30
** Copyright 1986-2022 Xilinx, Inc. All Rights Reserved.

INFO: hw_server application started
INFO: Use Ctrl-C to exit hw_server application

INFO: To connect to this hw_server instance use url: TCP:ba86b6047b8c:3121
```
Copiati ce este intre TCP: si :3121 si folositi-l ca 'url' la conexiune remote
Loading