Update docker file to use multistage build

Former-commit-id: f7a8f5ecab5532796ca4462acc1214f5392fb6ae
Former-commit-id: 0f85a545eef0467ae1d0129cdf8d992dbbb80072 [formerly 74524eb303c5ac0d8d55fe3219fb867c8104df71] [formerly 262d4dd258888853b8ca2fd24955dd26b4d78701 [formerly 3439945b19ac44d5b06e99bc35aab84155f1c48a [formerly 14d1035d3ec94627c06b8450bf2a582410f48b94] [formerly 14d1035d3ec94627c06b8450bf2a582410f48b94 [formerly 14d1035d3ec94627c06b8450bf2a582410f48b94 [formerly 962f5ddfa909bf4241f29de46a72df64ef3992ec]]]]]
Former-commit-id: 73fae6474844a1512bb7eb792058194530175d92 [formerly e5d0dc67369d4f7b277734df6bc69d95cdaae79f]
Former-commit-id: 58eacf41730f8f218e2a239d1407fcef512fa95e
Former-commit-id: 8ad509aba4c928c1a9c41d98b66e061283a0f460
Former-commit-id: 5a3a90ac30ab3676d63a82e81c3a7e3b459b1a82
Former-commit-id: 24385ec4b9f31817ae7d33362ca609fe838324b7 [formerly f17473045c7135f4d8b91b2a7faaf42e37a78b55]
Former-commit-id: e6b3cf86c980bde897cbae481443f344705fee97
This commit is contained in:
Erèbe 2017-10-22 14:58:16 +02:00
parent 247c7ac561
commit b16fad1031
8 changed files with 34 additions and 108 deletions

1
.dockerignore Normal file
View file

@ -0,0 +1 @@
.stack-work

31
Dockerfile Normal file
View file

@ -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"]

View file

@ -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;
}
}

View file

@ -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

View file

@ -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

View file

@ -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"]

View file

@ -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.

View file

@ -42,6 +42,7 @@ executable wstunnel
ghc-options: -threaded
-O3
-rtsopts "-with-rtsopts=-N"
-- ld-options: -static
build-depends: base
, bytestring
, classy-prelude