From 64bf81fcdaa2aab68899b2e6d713657a4e3c870a Mon Sep 17 00:00:00 2001 From: Nao1215 Date: Sat, 20 Nov 2021 14:59:49 +0900 Subject: [PATCH] Add docker target to Makefile. This target was created to test Mimixbox inside Docker. --- CHANGELOG.md | 4 +++- Dockerfile | 17 +++++++++++++++++ Makefile | 10 +++++++--- README.md | 21 +++++++++++++++++++++ docs/introduction/ja/Debugging.md | 10 +++++++++- 5 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 Dockerfile diff --git a/CHANGELOG.md b/CHANGELOG.md index be7194e..a903900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - +## [0.12.2] - 2021-11-20 +### Added + - docker target to Makefile. This target was created to test Mimixbox inside Docker. ## [0.12.1] - 2021-11-20 ### Added - base64 command. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b4fc2c5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM golang + +# Create mimixbox symbolic link in container. +COPY mimixbox /usr/local/bin/ +RUN mimixbox --full-install /usr/local/bin/ + +# Set root password +RUN echo 'root:password' | chpasswd + +# Create new user +RUN useradd mimixbox -m +RUN echo 'mimixbox:password' |chpasswd + +# If you want to administrator privileges, you become the root user +# RUN echo "mimixbox ALL=(ALL) ALL" >> /etc/sudoers + +CMD ["su", "-", "mimixbox"] \ No newline at end of file diff --git a/Makefile b/Makefile index 4fb3b2a..ad83443 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ build: deps ## Build mimixbox and make man-pages - go build "-ldflags=-s -w" -trimpath -o mimixbox cmd/mimixbox/main.go + CGO_ENABLED=0 go build "-ldflags=-s -w" -trimpath -o mimixbox cmd/mimixbox/main.go $(MAKE) doc $(MAKE) licenses @@ -14,6 +14,10 @@ clean: ## Clean project doc: ## Make man-pages ./scripts/mkManpages.sh +docker:build ## Run container for testing mimixbox + docker image build -t mimixbox/test:latest . + docker container run -it mimixbox/test:latest + install: ## Install mimixbox and man-pages on your system ./scripts/installer.sh @@ -31,8 +35,8 @@ deps: ## Dependency resolution for build go mod vendor .DEFAULT_GOAL := help -.PHONY: build clean doc install jail release deps - +.PHONY: build clean doc docker install jail release deps + help: @grep -E '^[0-9a-zA-Z_-]+[[:blank:]]*:.*?## .*$$' $(MAKEFILE_LIST) | sort \ | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[1;32m%-15s\033[0m %s\n", $$1, $$2}' \ No newline at end of file diff --git a/README.md b/README.md index 924d9f4..7c7e0b4 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,27 @@ The table below shows the tools used when developing the commands in the mimixbo | make | Used for build, run, test, etc | | gzip | Used for compress man pages | | install | Used for install serial binary and document in the system | +| docker| Used for testing Mimixbox inside Docker| +| debootstrap| Used for testing Mimixbox inside jail envrioment| + +# Debugging +### How to create docker(testing) environment +``` +# sudo apt install docker.io ※ If you have not installed Docker in Ubuntu. +$ make docker + +(注釈) Once the Docker image build is complete, you'll be inside the container. +$ +``` +### How to create jail(testing) environment +``` +$ sudo apt install debootstrap ※ If you have not installed debootstrap in Ubuntu. +$ make build ※ Build mimixbox binary +$ sudo make jail ※ Create jail environment at /tmp/mimixbox/jail + +$ sudo chroot /tmp/mimixbox/jail /bin/bash ※ Dive to jail +# mimixbox --full-install /usr/local/bin ※ Install MimixBox's command in jail +``` # Roadmap - Step1. Implements many common Unix commands (〜Version 0.x.x). diff --git a/docs/introduction/ja/Debugging.md b/docs/introduction/ja/Debugging.md index d917d60..5a8f6f6 100644 --- a/docs/introduction/ja/Debugging.md +++ b/docs/introduction/ja/Debugging.md @@ -9,8 +9,16 @@ MimixBoxは、Version1.0.0となるまで開発環境にインストールして 3. Raspberry Pi環境(イメージバックアップを残すと良い) 4. Virtual Box仮想環境(オススメしない) -上記は、オススメ順である。Docker環境は、Dockerfileを用意する予定である。jail環境は、DebianやUbuntu環境向けにスクリプトを用意している。利用手順は、以下の通りである。3〜4は、やや面倒な方法であるため、手順の説明は書かない予定である。 +上記は、オススメ順である。DockerとJail環境を利用したデバッグ方法のみ以下に示す。上記の3〜4は、やや面倒な方法であるため、手順の説明は書かない予定である。将来的にディストリビューションパッケージになれば、上記の3〜4.は現実的なデバッグ手段になるが、まだ早い。 +### Docker環境の作り方 +``` +# sudo apt install docker.io (注釈) Ubuntu環境の場合 +$ make docker +(注釈) Docker imageのビルドが完了すれば、コンテナの中に入る +$ +``` +### Jail環境の作り方 ``` $ sudo apt install debootstrap (注釈) Debian系の環境でdebootstrapをインストールしていない場合 $ make build (注釈) mimixboxバイナリの作成