Skip to content

Commit

Permalink
!1 docker 环境
Browse files Browse the repository at this point in the history
Merge pull request !1 from Osprey/docker-vscode
  • Loading branch information
Dozingfiretruck authored and gitee-org committed Aug 29, 2024
2 parents 355eb74 + ed4e245 commit f4233d8
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
1 change: 1 addition & 0 deletions .devcontainer/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build -f nes-dockerfile -t nes.osprey.io/nes-build-run .
48 changes: 48 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "osprey nes",

// Default path to open when attaching to a new container.
"workspaceFolder": "/home/osprey/work",
"image":"nes.osprey.io/nes-build-run",

// Set *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"cmake.automaticReconfigure": false,
"cmake.configureOnEdit": false
},
"extensions": [
// Put your favourite extensions here
// "mhutchie.git-graph",
// "eamodio.gitlens",
// "ms-vscode.cmake-tools",
// "ms-vscode.cpptools",
// "ms-vscode.cpptools-extension-pack",
]
}
},

// An array port numbers to forward
"forwardPorts": [],
// "postCreateCommand": "echo 'hello container'",
// Container user VS Code should use when connecting
"remoteUser": "osprey",
// Set environment variables for VS Code and sub-processes
"containerEnv": {
"MY_VARIABLE": "some-value",
// "DISPLAY": ":0"
},

"runArgs": [
"--network=host"
],
"privileged": true,
"mounts": [
// for audio device
"source=/dev/snd,target=/dev/snd,type=bind,consistency=cached",
// for video
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached"
]
}
82 changes: 82 additions & 0 deletions .devcontainer/nes-dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
FROM ubuntu:18.04 as builder

MAINTAINER Osprey

#docker build -f nes-dockerfile -t nes.osprey.io/nes-build-run .

# docker start nes-build
# docker attach nes-build
# docker exec -it nes-build /bin/bash


# 创建用户 cmd:id
ARG USERNAME=osprey
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

RUN apt-get update
# for cmd: add-apt-repository
RUN apt -y install software-properties-common dirmngr apt-transport-https lsb-release ca-certificates
RUN add-apt-repository ppa:xmake-io/xmake -y && apt-get update && apt-get install -y xmake
RUN apt-get install -y p7zip-full libsdl2-dev

RUN apt-get install -y git make gcc
# option
RUN apt-get install -y nano iputils-ping
# setting the password of root to 123456
RUN echo 'root:123456' | chpasswd

USER $USERNAME
ENV HOME=/home/$USERNAME

RUN mkdir /home/$USERNAME/work

WORKDIR /home/$USERNAME/work

RUN git clone https://gitee.com/Dozingfiretruck/nes && cd nes && xmake


###########################################
FROM ubuntu:18.04 as prod

#
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# 创建用户 cmd:id
ARG USERNAME=osprey
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

RUN apt-get update
RUN apt-get install -y p7zip-full libsdl2-dev

USER $USERNAME
ENV HOME=/home/$USERNAME

RUN mkdir /home/$USERNAME/work
WORKDIR /home/$USERNAME/work
RUN echo "PS1='\[\e[0;33m\]\u@\h\[\e[0m\]:\[\e[0;34m\]\w\[\e[0m\]\$ '" >> /home/$USERNAME/.bashrc

COPY --from=0 /home/$USERNAME/work/nes/build/linux/x86_64/release/nes .
COPY contra.nes .
COPY SuperMarioBrosWorld.nes .
#CMD ["~/work/nes contra.nes"]

# run cmd:
# docker run --name=nes-test --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev/snd:/dev/snd --privileged -e DISPLAY=unix$DISPLAY nes.osprey.io/nes-build-run /bin/bash -c "./nes contra.nes"

0 comments on commit f4233d8

Please sign in to comment.