From 6d06d71c31fc4778d6a6a6071c2d751a075b4216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nu=C8=9Biu?= Date: Mon, 1 Jan 2018 16:48:08 +0200 Subject: [PATCH] Adding support for Docker --- README.md | 29 +++++++++++++++++++++++++++++ server/Dockerfile | 24 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 server/Dockerfile diff --git a/README.md b/README.md index f1c518c..e5c54b9 100644 --- a/README.md +++ b/README.md @@ -88,3 +88,32 @@ The **config.json** file contains the following settings: 6. upload - Settings for the upload server. If one of the settings are changed, the server will reload the configuration. Except for the absoluteServePath. + +## Docker + +To build the image run: ```docker build -t simplft .``` and to run the server: + +``` +docker run -d \ + -it \ + --name devtest \ + --mount type=bind,source="/Users/denis/Downloads",target=/externalVolume \ + -p 8080:8080 -p 8081:8081 \ + simplft +``` + +* ```-p PORT1:PORT2``` - PORT1 is the host machine's port mapped to the container's PORT2 +* ```source="/Users/denis/Downloads"``` - This path should be changed to the path from where you want to serve files. + +To stop the server you will first need to identify the running container and the stop it via +```docker container stop CONTAINER ID``` + +##### Stopping the server + +``` +➜ server git:(master) ✗ docker container ls +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +90b6f00b1331 simplft "./simplFTP -confi..." 2 minutes ago Up 2 minutes 0.0.0.0:8081->8081/tcp, 0.0.0.0:32768->8080/tcp devtest +➜ server git:(master) ✗ docker container stop 90b6f00b1331 +90b6f00b1331 +``` \ No newline at end of file diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..ebcbca8 --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,24 @@ +# Golang is our base images. +FROM golang:1.7 + +# Make a directory called simplFT +RUN mkdir -p /go/src/github.com/metonimie/simplFT/server + +# Copy the current dir contents into simplFT +ADD . /go/src/github.com/metonimie/simplFT/server + +# Set the working directory to simplFT +WORKDIR /go/src/github.com/metonimie/simplFT/server + +# Make port 80 available to the world outside this container +EXPOSE 8080 + +# Install dependencies +RUN go get "github.com/zyxar/image2ascii/ascii" +RUN go get "github.com/spf13/viper" + +# Build the application +RUN go build ./simplFTP.go + +# Run simplFT when the container launches +CMD ["./simplFTP", "-config-name", "docker-config"]