Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions waspc/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*Dockerfile
58 changes: 58 additions & 0 deletions waspc/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# syntax=docker.io/docker/dockerfile:1

FROM docker.io/library/alpine AS ghc-base

RUN --mount=type=cache,target=/var/cache/apk <<EOF
apk update
# Dependency list from https://www.haskell.org/ghcup/install/#linux-alpine
apk add binutils-gold curl gcc g++ gmp-dev libc-dev libffi-dev make musl-dev ncurses-dev perl pkgconfig tar xz
EOF

ARG GHC_VERSION=8.10.7
RUN \
--mount=type=cache,target=/root/.ghcup/cache \
--mount=type=tmpfs,target=/root/.ghcup/logs \
<<EOF
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_MINIMAL=1 sh
source ~/.ghcup/env
ghcup config set cache true
ghcup install cabal --set latest
ghcup install ghc --set ${GHC_VERSION}
EOF

ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH"



FROM ghc-base AS builder

RUN --mount=type=cache,target=/var/cache/apk <<EOF
apk update
# Build script dependencies
apk add bash nodejs npm
# Cabal dependencies
apk add zlib-dev zlib-static
EOF


WORKDIR /work
COPY --link . .

RUN \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/root/.local/state/cabal/store \
--mount=type=cache,target=/root/.npm/_cacache \
--mount=type=tmpfs,target=/tmp \
<<EOF
set -euxo pipefail
cabal update
./run build:all:static
mkdir -p artifacts
./tools/make_binary_package.sh "artifacts/wasp.tar.gz"
EOF



FROM scratch AS output

COPY --from=builder /work/artifacts/wasp.tar.gz /artifacts/wasp.tar.gz
6 changes: 6 additions & 0 deletions waspc/run
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ WASP_PACKAGES_COMPILE="${SCRIPT_DIR}/tools/install_packages_to_data_dir.sh"
BUILD_HS_CMD="cabal build all"
BUILD_HS_FULL_CMD="cabal build all --enable-tests --enable-benchmarks"
BUILD_ALL_CMD="$WASP_PACKAGES_COMPILE && $BUILD_HS_CMD"
BUILD_ALL_STATIC_CMD="$WASP_PACKAGES_COMPILE && $BUILD_HS_CMD --enable-executable-static"

INSTALL_CMD="$WASP_PACKAGES_COMPILE && cabal install --overwrite-policy=always"

Expand Down Expand Up @@ -76,6 +77,8 @@ print_usage () {
"Builds the Haskell project."
print_usage_cmd "build:all" \
"Builds the Haskell project + all sub-projects (i.e. TS packages)."
print_usage_cmd "build:all:static" \
"Builds the Haskell project statically + all sub-projects (i.e. TS packages). Only useful for release builds."
print_usage_cmd "build:packages" \
"Builds the TypeScript projects under packages/."
echo ""
Expand Down Expand Up @@ -133,6 +136,9 @@ case $COMMAND in
build:all)
echo_and_eval "$BUILD_ALL_CMD"
;;
build:all:static)
echo_and_eval "$BUILD_ALL_STATIC_CMD"
;;
build:packages)
echo_and_eval "$WASP_PACKAGES_COMPILE"
;;
Expand Down
Loading