Skip to content

Commit

Permalink
Add docker target to Makefile. This target was created to test Mimixb…
Browse files Browse the repository at this point in the history
…ox inside Docker.
  • Loading branch information
nao1215 committed Nov 20, 2021
1 parent 17f4ddf commit 64bf81f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand All @@ -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}'
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
10 changes: 9 additions & 1 deletion docs/introduction/ja/Debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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バイナリの作成
Expand Down

0 comments on commit 64bf81f

Please sign in to comment.