Skip to content

Commit 86c1557

Browse files
committed
- add documentation in container
1 parent b64dc34 commit 86c1557

4 files changed

Lines changed: 56 additions & 19 deletions

File tree

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Makefile
2+
APPNAME=riotpot
3+
CURRENT_DIR=`pwd`
4+
PACKAGE_DIRS=`go list -e ./... | egrep -v "binary_output_dir|.git|mocks"`
5+
DOCKERFILE=docker/Dockerfile.documentation
6+
7+
# docker cmd below
8+
.PHONY: docker-build docker-run
9+
docker-build:
10+
docker build -f $(DOCKERFILE) . -t $(APPNAME)/v1
11+
docker-run: docker-build
12+
docker run -p 6060:6060 -it $(APPNAME)/v1

docker-compose.dev.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
"""
2-
This Docker Compose file is meant to be used on a development
3-
environment for testing.
4-
This environment includes a fake local network, a local database and
5-
a volume mounted with the code to see changes on the go.
6-
"""
1+
# This Docker Compose file is meant to be used on a development
2+
# environment for testing.
3+
# This environment includes a fake local network, a local database and
4+
# a volume mounted with the code to see changes on the go.
75

86
version: "3.8"
97
services:

docker/Dockerfile.documentation

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Start from the latest golang base image
2+
FROM golang:latest
3+
4+
# env setup for reusability
5+
ENV APP_NAME=riotpot
6+
ENV WORKING_DIR=$GOPATH/src/github.com/aau/$APP_NAME
7+
8+
# get godoc
9+
RUN go get golang.org/x/tools/cmd/godoc
10+
11+
# Set the working directory to golang working space
12+
WORKDIR $WORKING_DIR
13+
14+
# Copy the current directory contents into the container at current directory
15+
ADD riotpot/ .
16+
17+
CMD godoc -http=:6060
18+

riotpot/main.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,35 @@ import (
1313

1414
var wg sync.WaitGroup
1515

16+
// main starts all the submodules containing the emulators.
17+
// It is the first function called when the application is run.
18+
// It also acts as an orchestrator, which dictates the functioning of the application.
1619
func main() {
17-
1820
if environ.Getenv("SERVICES", "") == "" {
19-
wg.Add(1)
21+
wg.Add(1) // add a goroutine to the stack, blocking until all services are up.
22+
23+
//----------------
24+
// Add here all the services that must be run by default if either there is no
25+
// environment file or variables which define this behaviour otherwise.
26+
//----------------
2027
go telnet_serv()
2128
go http_serv()
22-
go ssh_serv() //Starts SSH Server
29+
go ssh_serv()
2330
//go trydy_proxy_serv()
24-
wg.Wait()
25-
} else {
31+
//----------------
2632

33+
wg.Wait() // wait until the goroutines call Done or are over.
34+
} else {
35+
// TODO: add the logic to the loop.
2736
}
2837
}
2938

39+
/*
40+
Print to the console if the server successfully started
41+
@service: the name of the service
42+
@out: the integer result of the server started, 1 or 0 , where 0 is a falsy value.
43+
*/
3044
func serv_out(service string, out int) {
31-
/*
32-
Print to the console if the server successfully started
33-
@service: the name of the service
34-
@out: the integer result of the server started, 1 or 0 , where 0 is a falsy value.
35-
*/
3645

3746
if out > 0 {
3847
fmt.Printf("%s Server Started", service)
@@ -41,18 +50,18 @@ func serv_out(service string, out int) {
4150
}
4251
}
4352

53+
/*Start SSH server*/
4454
func ssh_serv() {
45-
/*Start SSH server*/
4655
sshd.SSHServer()
4756
}
4857

58+
/* Start Telnet server */
4959
func telnet_serv() {
50-
/* Start Telnet server */
5160
telnetd.TelnetServer()
5261
}
5362

63+
/* Start HTTP server */
5464
func http_serv() {
55-
/* Start HTTP server */
5665
httpd.HttpServer()
5766
}
5867

0 commit comments

Comments
 (0)