diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8ee1bf9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.stack-work diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7fbb072 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM alpine:3.6 as builder +MAINTAINER github@erebe.eu + +RUN apk --no-cache add --repository http://dl-cdn.alpinelinux.org/alpine/edge/community \ + ca-certificates git ghc upx curl musl-dev gmp-dev zlib-dev pcre-dev +RUN curl -sSL https://get.haskellstack.org/ | sh + +COPY stack.yaml /mnt +COPY *.cabal /mnt +WORKDIR /mnt +RUN rm -rf ~/.stack && \ + stack config set system-ghc --global true && \ + stack setup && \ + stack install --split-objs --ghc-options="-fPIC -fllvm" --only-dependencies + +COPY . /mnt + +RUN stack install --split-objs --ghc-options="-fPIC -fllvm" +RUN upx --ultra-brute /root/.local/bin/wstunnel + + + +FROM alpine:latest as runner +MAINTAINER github@erebe.eu + +WORKDIR /root +COPY --from=builder /root/.local/bin/wstunnel . +RUN chmod +x ./wstunnel + +ENTRYPOINT ["./wstunnel"] + diff --git a/deploy/config/wstunnel.nginx b/deploy/config/wstunnel.nginx deleted file mode 100644 index df76e9d..0000000 --- a/deploy/config/wstunnel.nginx +++ /dev/null @@ -1,21 +0,0 @@ -server { - listen *:443 ssl; - listen [::]:443 ssl; - server_name erebe.eu; - server_name 195.154.67.145; - server_name 2001:bc8:3d8f::cafe; - - - location / { - proxy_read_timeout 1800s; - proxy_pass http://127.0.0.1:{{ listen_port }}; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - -} diff --git a/deploy/config/wstunnel.service b/deploy/config/wstunnel.service deleted file mode 100644 index 0ca3202..0000000 --- a/deploy/config/wstunnel.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=wstunnel server -Wants=network.target -After=network.target - -[Service] -Type=simple -User=wstunnel -ExecStart=/usr/local/bin/wstunnel --server ws://127.0.0.1:{{ listen_port }} -r 127.0.0.1:22 -Restart=always - -[Install] -WantedBy=multi-user.target diff --git a/deploy/server.yml b/deploy/server.yml deleted file mode 100755 index f02248b..0000000 --- a/deploy/server.yml +++ /dev/null @@ -1,60 +0,0 @@ -- hosts: server - remote_user: root - - vars: - # Username - user: wstunnel - listen_port: 9999 - - tasks: - - name: Create user {{ user }} - user: name={{ user }} - comment="{{ user }} user" - shell=/bin/false - createhome=no - - - name: Install wstunnel app - copy: src=config/wstunnel - dest=/usr/local/bin/ - owner=wstunnel - group=wstunnel - mode=u+rwx - - ################################ - # NGINX - ################################ - - name: Add nginx config - template: src=config/wstunnel.nginx - dest=/etc/nginx/sites-available/ - notify: reload nginx - - - name: Symlink nginx config - file: src=/etc/nginx/sites-available/wstunnel.nginx - dest=/etc/nginx/sites-enabled/default - state=link - - - name: Nginx started - service: name=nginx state=started enabled=true - - - ################################ - # SYSTEMD - ################################ - - name: Copy systemd service - template: src=config/wstunnel.service - dest=/usr/lib/systemd/system/ - notify: reload wstunnel - - - name: reload systemd - command: systemctl daemon-reload - - - name: wstunnel started - service: name=wstunnel state=started enabled=true - - - handlers: - - name: reload nginx - service: name=nginx state=reloaded enabled=true - - - name: reload wstunnel - service: name=wstunnel state=restarted enabled=true diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 3922d7a..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM alpine:latest -MAINTAINER github@erebe.eu - - -RUN adduser -D wstunnel -ADD https://github.com/erebe/wstunnel/blob/master/bin/wstunnel_x86_64?raw=true /home/wstunnel/wstunnel -RUN chmod +x /home/wstunnel/wstunnel - -EXPOSE 8080 -USER wstunnel - -ENTRYPOINT ["/home/wstunnel/wstunnel"] - diff --git a/stack.yaml b/stack.yaml index a9eaf31..ca707c7 100644 --- a/stack.yaml +++ b/stack.yaml @@ -15,7 +15,7 @@ # resolver: # name: custom-snapshot # location: "./custom-snapshot.yaml" -resolver: lts-7.2 +resolver: lts-9.9 # User packages to be built. # Various formats can be used as shown in the example below. diff --git a/wstunnel.cabal b/wstunnel.cabal index 112d2e4..dc123a6 100644 --- a/wstunnel.cabal +++ b/wstunnel.cabal @@ -42,6 +42,7 @@ executable wstunnel ghc-options: -threaded -O3 -rtsopts "-with-rtsopts=-N" +-- ld-options: -static build-depends: base , bytestring , classy-prelude