Skip to content

Commit

Permalink
Merge pull request #1 from CaKrome/switch_to_docker_compose
Browse files Browse the repository at this point in the history
Switch to docker compose
  • Loading branch information
CaKrome authored Jun 2, 2024
2 parents 6a00f77 + 315f0e8 commit ea0df47
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 105 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Image CI
name: Build Docker Image

on:
workflow_dispatch:
Expand All @@ -15,6 +15,6 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Build the amd64 Docker image
working-directory: ./amd64
run: docker build . --file Dockerfile --tag cakrome/ss-rust:$(date +%s)
- name: Build Docker image
working-directory: .
run: docker compose build
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM quay.io/almalinux/almalinux:9 AS compile-image

ENV SHADOWSOCKS_VER=1.19.2
ENV V2RAY_PLUGIN_VER=1.3.2

WORKDIR /root

RUN set -ex && dnf upgrade -y && dnf install -y binutils wget make gcc xz

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

RUN wget https://github.com/shadowsocks/shadowsocks-rust/archive/refs/tags/v${SHADOWSOCKS_VER}.tar.gz
RUN tar -xf v${SHADOWSOCKS_VER}.tar.gz

RUN set -ex \
&& source "$HOME/.cargo/env" \
&& cd shadowsocks-rust-${SHADOWSOCKS_VER} \
&& TARGET=release make build

RUN strip /root/shadowsocks-rust-${SHADOWSOCKS_VER}/target/release/sslocal
RUN strip /root/shadowsocks-rust-${SHADOWSOCKS_VER}/target/release/ssmanager
RUN strip /root/shadowsocks-rust-${SHADOWSOCKS_VER}/target/release/ssserver
RUN strip /root/shadowsocks-rust-${SHADOWSOCKS_VER}/target/release/ssservice
RUN strip /root/shadowsocks-rust-${SHADOWSOCKS_VER}/target/release/ssurl

RUN mv /root/shadowsocks-rust-${SHADOWSOCKS_VER}/target/release/sslocal /root/
RUN mv /root/shadowsocks-rust-${SHADOWSOCKS_VER}/target/release/ssmanager /root/
RUN mv /root/shadowsocks-rust-${SHADOWSOCKS_VER}/target/release/ssserver /root/
RUN mv /root/shadowsocks-rust-${SHADOWSOCKS_VER}/target/release/ssservice /root/
RUN mv /root/shadowsocks-rust-${SHADOWSOCKS_VER}/target/release/ssurl /root/

FROM quay.io/almalinux/almalinux:9 AS runtime-image

RUN set -ex && dnf upgrade -y && dnf clean all

RUN useradd --create-home serviceuser

WORKDIR /home/serviceuser

USER serviceuser

COPY server_block_local.acl .
COPY --from=compile-image /root/sslocal /usr/local/bin/
COPY --from=compile-image /root/ssmanager /usr/local/bin/
COPY --from=compile-image /root/ssserver /usr/local/bin/
COPY --from=compile-image /root/ssservice /usr/local/bin/
COPY --from=compile-image /root/ssurl /usr/local/bin/

ENV TZ=America/Toronto

CMD [ "ssservice", "server", "-c", "/etc/shadowsocks-rust/config.json", "--acl", "server_block_local.acl" ]
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
# shadowsocks-rust-docker
Docker/Podman deployment solution of [shadowsocks-rust](https://github.com/shadowsocks/shadowsocks-rust)
Docker deployment solution of [shadowsocks-rust](https://github.com/shadowsocks/shadowsocks-rust)

# Usage

```bash
git clone https://github.com/CaKrome/shadowsocks-rust-docker.git

#If your server is using amd64 architecture
cd shadowsocks-rust-docker/amd64
# Build the docker image
docker compose build

#If your server is using arm64 architecture
cd shadowsocks-rust-docker/arm64
# Now edit the file config.json to the configuation you like and also port in docker-compose.yml if you changed the default port.

#Build the docker image
docker build . -t cakrome/ss-rust

#Now create a file called config.json in /etc/shadowsocks-rust and put your configuration there, we have a sample configuation file(sample_conf.json) for reference

#Run the built docker image
docker run -d -p [port]:[port] -p [port]:[port]/udp --name ss-rust --restart=always -v /etc/shadowsocks-rust:/etc/shadowsocks-rust cakrome/ss-rust
# Bring the service up
docker compose up -d
```
When using podman, replace `docker` with `podman`


30 changes: 0 additions & 30 deletions amd64/Dockerfile

This file was deleted.

30 changes: 0 additions & 30 deletions arm64/Dockerfile

This file was deleted.

25 changes: 0 additions & 25 deletions arm64/server_block_local.acl

This file was deleted.

1 change: 0 additions & 1 deletion sample_conf.json → config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
"timeout":300,
"method":"aes-256-gcm",
"mode":"tcp_and_udp"
"fast_open":true
}
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
shadowsocks-rust:
build:
context: .
dockerfile: Dockerfile
container_name: ss-rust
ports:
- "8388:8388/tcp"
- "8388:8388/udp"
volumes:
- type: bind
source: ./config.json
target: /etc/shadowsocks-rust/config.json
restart: unless-stopped
File renamed without changes.

0 comments on commit ea0df47

Please sign in to comment.