Skip to content

Commit

Permalink
Update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
erebe committed Sep 24, 2023
1 parent 42f0db9 commit cb89765
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: extract Artifact
run: |
docker cp $(docker create ghcr.io/erebe/wstunnel:latest /bin/sh -c 'sleep 5000'):/wstunnel .
docker run --rm -ti -v $(pwd):/data ghcr.io/erebe/wstunnel:latest
./wstunnel
- uses: actions/upload-artifact@v1
Expand Down
41 changes: 13 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
# Build Cache image
FROM fpco/stack-build-small:lts-19.2 as builder-cache
FROM alpine:3.18 as builder

COPY stack.yaml /mnt
COPY *.cabal /mnt
WORKDIR /mnt
RUN rm -rf ~/.stack && \
stack config set system-ghc --global true && \
stack setup && \
stack install --ghc-options="-fPIC" --only-dependencies
RUN apk --no-cache add ca-certificates git ghc curl musl-dev gmp-dev zlib-dev zlib-static pcre-dev xz make
RUN curl -sSL https://github.com/commercialhaskell/stack/releases/download/v2.11.1/stack-2.11.1-linux-$(uname -m)-static.tar.gz | tar xvz && \
mv stack*/stack /usr/bin



# Build phase
FROM builder-cache as builder
# FROM ghcr.io/erebe/wstunnel:build-cache as builder
COPY . /mnt
WORKDIR /mnt
RUN rm -rf ~/.stack && \
stack config set system-ghc --global true && \
echo ' ld-options: -static' >> wstunnel.cabal ; \
stack install --no-install-ghc --system-ghc --ghc-options="-fPIC" --executable-stripping

RUN echo ' ld-options: -static' >> wstunnel.cabal ; \
stack install --ghc-options="-fPIC"
#RUN upx /root/.local/bin/wstunnel



# Final Image
FROM alpine:latest as runner

LABEL org.opencontainers.image.source https://github.com/erebe/server

COPY --from=builder /root/.local/bin/wstunnel /
RUN adduser -D abc && chmod +x /wstunnel

USER abc
WORKDIR /
FROM alpine:3.18 as final

CMD ["/wstunnel"]
COPY --from=builder /root/.local/bin/wstunnel .

VOLUME /data
CMD cp wstunnel /data
4 changes: 2 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# resolver:
# name: custom-snapshot
# location: "./custom-snapshot.yaml"
resolver: lts-19.2
resolver: nightly-2023-04-24

# User packages to be built.
# Various formats can be used as shown in the example below.
Expand All @@ -35,7 +35,7 @@ packages:
# Dependency packages to be pulled from upstream that are not in the resolver
# using the same syntax as the packages field.
# (e.g., acme-missiles-0.3)
extra-deps: [ ]
extra-deps: []

# Override default flag values for local packages and extra-deps
# flags: {}
Expand Down

0 comments on commit cb89765

Please sign in to comment.