Skip to content

Commit 75b8956

Browse files
committed
Cleanup and added makefile. Bumped version. Closes #1 and #2
1 parent 71b0866 commit 75b8956

File tree

5 files changed

+97
-21
lines changed

5 files changed

+97
-21
lines changed

Makefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Bump these on release, and for now manually update the deployment files:
2+
# docker-compose.yml, stack.yml and package.json
3+
VERSION_MAJOR ?= 0
4+
VERSION_MINOR ?= 4
5+
BUILD_NUMBER ?= 0
6+
PATCH_STRING ?=
7+
8+
VERSION_STRING = $(VERSION_MAJOR).$(VERSION_MINOR).$(BUILD_NUMBER)$(PATCH_STRING)
9+
10+
IMAGE_TAG ?= $(VERSION_MAJOR).$(VERSION_MINOR).$(BUILD_NUMBER)
11+
REGISTRY_USER ?= rajchaudhuri
12+
13+
.PHONY: all
14+
all: client server
15+
16+
.PHONY: public
17+
public:
18+
cp -r public/* out/
19+
20+
out/js/client.js: client/*.js
21+
npm run build-client-release
22+
23+
.PHONY: client
24+
client: public out/js/client.js
25+
26+
.PHONY: client-debug
27+
client-debug: public client/*.js
28+
npm run build-client-debug
29+
30+
out/voxel-dockerserver: server/*.go
31+
CGO_ENABLED='0' go build -o out/voxel-dockerserver -ldflags "-X 'main.version=$(VERSION_STRING)'" server/*.go
32+
33+
.PHONY: server
34+
server: out/voxel-dockerserver
35+
36+
.PHONY: debug
37+
debug: public client-debug server
38+
39+
.PHONY: build-docker
40+
build-docker:
41+
docker image build -t $(REGISTRY_USER)/voxel-dockerclient:$(VERSION_STRING) -f Dockerfile .
42+
43+
.PHONY: run-docker
44+
run-docker: build-docker
45+
docker container run --rm --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock --publish 8080:8080 $(REGISTRY_USER)/voxel-dockerclient:$(VERSION_STRING)
46+
47+
.PHONY: clean-docker
48+
clean-docker:
49+
docker image rm $(REGISTRY_USER)/voxel-dockerclient:$(VERSION_STRING)
50+
51+
.PHONY: clean
52+
clean:
53+
rm -rf out/*

README.md

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ The dockercraft project turns the official Minecraft client into a docker client
77
## What is it not?
88
voxel-dockerclient is not a serious tool for working with docker. It's a fun project (which may grow up to be a teaching aid someday).
99

10-
> WARNING: Please use voxel-dockerclient on your local machine only.
11-
> It currently doesn't support any authentication.
10+
> WARNING: Please use voxel-dockerclient with care.
11+
> It requires access to the docker socket.
1212
1313
## How to run voxel-dockerclient
14+
### Try it on Play With Docker
15+
The easiest way:
16+
17+
[![Try in PWD](https://raw.githubusercontent.com/play-with-docker/stacks/master/assets/images/button.png)](https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/rajch/voxel-dockerclient/master/stack.yml)
18+
1419
### Using the docker image
15-
The easiest way is to pull the docker image, and run from that. The steps are as follows:
20+
The next easiest way is to pull the docker image, and run from that. The steps are as follows:
1621

1722
1. Pull the docker image with
1823

@@ -23,30 +28,28 @@ The easiest way is to pull the docker image, and run from that. The steps are as
2328
2. Run it with:
2429

2530
```
26-
docker run -d -p 5000:80 -v /var/run/docker.sock:/var/run/docker.sock rajchaudhuri/voxel-dockerclient
31+
docker run -d -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock rajchaudhuri/voxel-dockerclient
2732
```
2833

2934
> The `-v /var/run/docker.sock:/var/run/docker.sock` is *very important*.
3035
> This makes the UNIX socket, which the docker daemon listens to by default, available to the container.
3136
> The container needs this to proxy a subset of the Docker remote API to voxel-dockerclient.
3237
> If you leave this out by mistake, voxel-dockerclient will not work.
3338
34-
3. Point your browser to the container. If you run docker directly on your Linux machine, browse to: `http://localhost:5000`.
39+
3. Point your browser to the container. If you run docker directly on your Linux machine, browse to: `http://localhost:8080`.
3540
If you use docker-machine (for example, with the Docker Toolbox on Windows), find the IP address of your docker machine with
3641

3742
```
3843
docker-machine ip default
3944
```
40-
and then browse to that IP address using the port that you mapped in step 2. E.g.: `http://192.17.22.1:5000`
45+
and then browse to that IP address using the port that you mapped in step 2. E.g.: `http://192.17.22.1:8080`
4146

4247
### Building with node.js and golang
43-
Alternatively, if you have node.js and golang installed on your docker host, you can clone the github repository, and build and run voxel-dockerclient yourself. The steps are:
48+
Alternatively, if you have node.js (>=v12.19.0) and golang (>=go1.16.4) installed on your docker host, you can clone the github repository, and build and run voxel-dockerclient yourself. The steps are:
4449

4550
1. Clone the github repository into your Go workspace with:
4651

4752
```
48-
mkdir -p "$GOPATH/src/github.com/rajch"
49-
cd "$GOPATH/src/github.com/rajch"
5053
git clone https://github.com/rajch/voxel-dockerclient.git
5154
```
5255
2. Change to the cloned directory and run
@@ -57,9 +60,14 @@ Alternatively, if you have node.js and golang installed on your docker host, you
5760
3. Run
5861

5962
```
60-
npm run build-all
63+
npm run build
6164
npm run run-docker
6265
```
66+
or, if you are on Linux, or OSX, or WSL:
67+
```
68+
make
69+
make run-docker
70+
```
6371
4. Browse to `http://localhost:8080`
6472

6573
Your logged-in user needs to be a member of the `docker` group for this to work.
@@ -79,25 +87,31 @@ docker build -t voxel-dockerclient:local .
7987
```
8088
3. Run
8189
```
82-
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 8081:80 voxel-dockerclient:local
90+
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 voxel-dockerclient:local
91+
```
92+
4. Browse to `http://localhost:8080`
93+
94+
Or, you could use the provided docker compose manifest file, by running:
95+
96+
```
97+
docker-compose up -d
8398
```
84-
4. Browse to `http://localhost:8081`
8599

86100
Your logged-in user needs to be a member of the `docker` group for this to work.
87101

88102
## How to use voxel-dockerclient
89103
Instructions are available [here](https://rajch.github.io/voxel-dockerclient/).
90104

91105
## Browser compatibility
92-
voxel-dockerclient has been tested using recent Chrome and Firefox browsers, on Linux and Windows. Regrettably (*I mean it. I actually like that old browser*), it does not work with Internet Explorer.
106+
voxel-dockerclient has been tested using recent Chrome and Firefox browsers, on Linux and Windows.
93107

94108
## What's next?
95109
I intend to add the following capabilities quickly:
96110
* ~~`docker logs` equivalent~~ ** DONE
97111
* ~~`docker attach` equivalent~~ ** DONE
98112
* `docker pull` equivalent
99113
* A better interface for the `create` command
100-
* *Some* security
114+
* ~~*Some* security~~ ** DONE
101115

102116
In the pipeline, further down, are:
103117
* volumes
@@ -109,7 +123,7 @@ I don't really know how far I want to take this. I do want voxel-dockerclient to
109123
## How does it work?
110124
~~On the server, voxel-dockerclient uses [Express](http://expressjs.com/) and the excellent [dockerode](https://github.com/apocas/dockerode) node module to provide a proxy for a subset of the Docker remote API.
111125
The voxel-dockerclient server is simply nginx, proxying the docker daemon's UNIX socket.~~
112-
The voxel-dockerclient server is a tiny golang program, which serves the client HTML/CSS/javascript, and provides a proxy for the docker API. At the moment, it proxies the full API with no authorization. This will change.
126+
The voxel-dockerclient server is a tiny golang program, which serves the client HTML/CSS/javascript, and provides a proxy for the docker API. At the moment, it proxies the full API with ~~no~~ some authorization. ~~This will change.~~
113127

114128
On the client, it uses the brilliant [voxeljs](http://voxeljs.com/) family of node modules to render the UI, and the [axios](https://github.com/mzabriskie/axios) node module to communicate with the proxied API.
115129

@@ -123,4 +137,4 @@ I would like to thank:
123137
* The fine folk of @docker, for Docker
124138
* The fine folk behind the voxeljs family of modules. @github/maxogden, @github/kumavis, @github/deathcap, @github/substack et al. These are really nice.
125139
* The authors of the dockerode and axios modules, although I'm not using dockerode any more.
126-
* My partner, Chitra Raghavan, for contributing the player model, testing, and bearing with me while I was building this
140+
* My partner, Chitra Raghavan (@github/chitradoc), for contributing the player model, testing, and bearing with me while I was building this

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ volumes:
55

66
services:
77
vdcservice:
8-
image: rajchaudhuri/voxel-dockerclient:latest
8+
image: rajchaudhuri/voxel-dockerclient:0.4.0
99
build:
1010
context: .
1111
dockerfile: Dockerfile

package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
{
22
"name": "voxel-dockerclient",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "An experimental minecraft-like docker client, built using voxel.js.",
55
"main": "",
6+
"config": {
7+
"registry_user": "rajchaudhuri"
8+
},
69
"scripts": {
10+
"check-env": "node -e 'console.log(process.env)'",
711
"test": "echo \"Error: no test specified\" && exit 1",
812
"build-public": "copyfiles --up 1 public/css/* public/fonts/* public/js/* public/textures/* public/*.html out && copyfiles -f node_modules/xterm/dist/xterm.js out/js && copyfiles -f node_modules/xterm/dist/xterm.css out/css",
913
"clean-public": "rimraf out/css out/fonts out/js/*dialog.js out/js/xterm.js out/textures out/*.html",
1014
"build-client-debug": "browserify --debug client/main.js -o out/js/client.js",
1115
"build-client-release": "browserify client/main.js -o out/js/client.js",
1216
"clean-client": "rimraf out/js/client.js",
13-
"build-server": "CGO_ENABLED='0' go build -o out/voxel-dockerserver server/*.go",
17+
"build-server": "CGO_ENABLED='0' go build -o out/voxel-dockerserver -ldflags \"-X 'main.version=${npm_package_version}'\" server/*.go",
1418
"clean-server": "rimraf out/server",
1519
"build-debug": "npm run build-public && npm run build-client-debug && npm run build-server",
1620
"build": "npm run build-public && npm run build-client-release && npm run build-server",
17-
"clean": "rimraf out/",
21+
"build-docker": "docker image build -t ${npm_package_config_registry_user}/voxel-dockerclient:${npm_package_version} -f Dockerfile .",
22+
"run-docker": "npm run build-docker && docker container run --rm --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock --publish 8080:8080 ${npm_package_config_registry_user}/voxel-dockerclient:${npm_package_version}",
23+
"clean": "rimraf out/*",
1824
"standard": "standard client/** public/js/**"
1925
},
2026
"repository": {
@@ -51,4 +57,4 @@
5157
"rimraf": "^2.6.3",
5258
"standard": "^10.0.3"
5359
}
54-
}
60+
}

server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"time"
1212
)
1313

14+
var version = ""
15+
1416
func main() {
1517
// Verify presence of docker socket
1618
conn, err := net.Dial("unix", "/var/run/docker.sock")
@@ -84,6 +86,7 @@ func main() {
8486
}()
8587

8688
// Start listening using the server
89+
log.Printf("Voxel-dockerserver version: %v\n", version)
8790
log.Println("Server starting on port 8080...")
8891
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
8992
log.Fatalf("The server failed with the following error:%v\n", err)

0 commit comments

Comments
 (0)