From dc68b1b30ff1c741456c2f594c8a1003a35e9f31 Mon Sep 17 00:00:00 2001 From: "0Knot (0KN)" <48816852+0Knot@users.noreply.github.com> Date: Sun, 11 Aug 2024 01:14:39 +0800 Subject: [PATCH 1/4] Join Docker support Developed Dockerfile to support Docker Go compilation and export images --- Dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c5c0e482 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +# Use the official Alpine-based Golang image as the build stage +FROM golang:1.18-alpine AS builder + +# Set the working directory +WORKDIR /go/src/github.com/quackduck/devzat + +# Copy the project source code into the container +COPY . . + +# Install project dependencies +RUN go mod download + +# Build the project +RUN go build -o devzat . + + + + +# Use the latest Alpine Linux image as the base for the final image +FROM alpine:latest + +# Install necessary tools +RUN apk add --no-cache openssh-server + +# Copy the compiled binary to the final image +COPY --from=builder /go/src/github.com/quackduck/devzat /usr/local/bin/devzat + +# Generate the SSH host key +RUN ssh-keygen -qN '' -f /etc/ssh/ssh_host_rsa_key + +# Expose the SSH port +EXPOSE 22 + +# Configure and start the SSH service +RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config +CMD ["/usr/sbin/sshd", "-D"] + +# Run the application (This line is commented out because the main service is the SSH server) +# CMD ["devzat"] \ No newline at end of file From 0219b23d552301c32ffe33a7ed55d956e9f548a3 Mon Sep 17 00:00:00 2001 From: "0Knot (0KN)" <48816852+0Knot@users.noreply.github.com> Date: Sun, 11 Aug 2024 01:20:07 +0800 Subject: [PATCH 2/4] Update README.md Notes on the creation and use of Docker images --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index c9ea57cc..85581ffd 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,17 @@ devzat # run! the default config is used & written automatically ``` These commands download, build, setup and run a Devzat server listening on port 2221, the default port (change by setting `$PORT`). +Docker start: +```shell +git clone https://github.com/quackduck/devzat && cd devzat +docker build -t devzat . +docker run -d --name devzat -p 2222:22 devzat + +# Start enjoying +ssh yourname@127.0.0.1 -p 2222 +``` + + Check out the [Admin's Manual](Admin's%20Manual.md) for complete self-host documentation! ### Permission denied? From 709f08e414e61c51584998ea28e5e5ae7036ef9a Mon Sep 17 00:00:00 2001 From: "0Knot (0KN)" <48816852+0Knot@users.noreply.github.com> Date: Sun, 11 Aug 2024 15:22:09 +0800 Subject: [PATCH 3/4] Update Dockerfile Fix misconfiguration from test files --- Dockerfile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index c5c0e482..ae919e9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,17 +23,13 @@ FROM alpine:latest RUN apk add --no-cache openssh-server # Copy the compiled binary to the final image -COPY --from=builder /go/src/github.com/quackduck/devzat /usr/local/bin/devzat +COPY --from=builder /go/src/github.com/quackduck/devzat/devzat /usr/local/bin/devzat # Generate the SSH host key RUN ssh-keygen -qN '' -f /etc/ssh/ssh_host_rsa_key # Expose the SSH port -EXPOSE 22 - -# Configure and start the SSH service -RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config -CMD ["/usr/sbin/sshd", "-D"] +EXPOSE 2221 443 5555 # Run the application (This line is commented out because the main service is the SSH server) -# CMD ["devzat"] \ No newline at end of file +CMD ["/usr/local/bin/devzat"] From ca1ea63ccee31412f839e13f8bad6470e496c6d3 Mon Sep 17 00:00:00 2001 From: "0Knot (0KN)" <48816852+0Knot@users.noreply.github.com> Date: Sun, 11 Aug 2024 15:28:26 +0800 Subject: [PATCH 4/4] Update README.md Improve Docker usage --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 85581ffd..f932bc74 100644 --- a/README.md +++ b/README.md @@ -65,12 +65,38 @@ Docker start: ```shell git clone https://github.com/quackduck/devzat && cd devzat docker build -t devzat . -docker run -d --name devzat -p 2222:22 devzat +docker run -d --name devzat -p 2221:2221 -p 443:443 devzat # Or consider using docker compose # Start enjoying ssh yourname@127.0.0.1 -p 2222 ``` +Docker Compose: +First use: +```shell +git clone https://github.com/quackduck/devzat && cd devzat +docker build -t devzat . +``` + +Create a docker-compose.yml file in the appropriate location: +```yaml +--- +services: + devzat: + image: devzat + container_name: devzat + environment: + - DEVZAT_CONFIG=/etc/devzat/devzat.yml #Create it by referring to the sample configuration file + volumes: + - ./devzat.yml:/etc/devzat/devzat.yml + - ./data:/opt/devzat + ports: + - "2221:2221" + - "443:443" + #- "5555:5555" #Optional + restart: always +``` + Check out the [Admin's Manual](Admin's%20Manual.md) for complete self-host documentation!