Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker + Alpine = Can't build! #249

Closed
srfrnk opened this issue Mar 4, 2018 · 4 comments
Closed

Docker + Alpine = Can't build! #249

srfrnk opened this issue Mar 4, 2018 · 4 comments

Comments

@srfrnk
Copy link

srfrnk commented Mar 4, 2018

Save this as Dockerfile:

FROM node:9.3.0-alpine
RUN npm install aerospike

Then run:

docker build .

And get this:

.
.
.
> aerospike@3.2.0 install /app/node_modules/aerospike
> node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
.
.
.

However this works:

FROM node:9.3.0
RUN npm install aerospike

Might be worth putting into the docs at least.

@jhecking
Copy link
Contributor

jhecking commented Mar 5, 2018

This is a known limitation / feature (depending on who you ask!) of the node:alpine image. Does the solution suggested in this issue help?

@srfrnk
Copy link
Author

srfrnk commented Mar 5, 2018

Sadly no:

> aerospike@3.2.0 install /app/node_modules/aerospike
> node-gyp rebuild

make: Entering directory '/app/node_modules/aerospike/build'
  TOUCH binding_gyp_aerospike_client_c_target_Installing_Aerospike_C_Client_dependency.intermediate
  ACTION binding_gyp_aerospike_client_c_target_Installing_Aerospike_C_Client_dependency binding_gyp_aerospike_client_c_target_Installing_Aerospike_C_Client_dependency.intermediate
/bin/sh: scripts/aerospike-client-c.sh: not found
make: *** [aerospike-client-c.target.mk:17: binding_gyp_aerospike_client_c_target_Installing_Aerospike_C_Client_dependency.intermediate] Error 127
rm binding_gyp_aerospike_client_c_target_Installing_Aerospike_C_Client_dependency.intermediate
make: Leaving directory '/app/node_modules/aerospike/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:159:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Linux 4.13.0-36-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /app/node_modules/aerospike
gyp ERR! node -v v9.3.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

@jhecking
Copy link
Contributor

jhecking commented Mar 6, 2018

I am not sure why you are getting this error: "scripts/aerospike-client-c.sh: not found".

But in any case, for Alpine Linux we do not provide official releases for the Aerospike C client, which is required to build the Node.js client. So the C client needs to be compiled from source first. Here is a Dockerfile that does exactly that:

# Stage 1: Build Aerospike C client
FROM alpine:3.6 as c-builder
WORKDIR /src

ENV AS_C_VERSION 4.3.5

RUN apk update
RUN apk add --no-cache \
    build-base \
    bash linux-headers \
    libuv libuv-dev \
    openssl openssl-dev \
    lua5.1 lua5.1-dev

RUN wget https://artifacts.aerospike.com/aerospike-client-c/${AS_C_VERSION}/aerospike-client-c-src-${AS_C_VERSION}.zip \
    && unzip aerospike-client-c-src-${AS_C_VERSION}.zip \
    && mv aerospike-client-c-src-${AS_C_VERSION} aerospike-client-c \
    && cd aerospike-client-c \
    && make EVENT_LIB=libuv

# Stage 2: Build Aerospike Node.js client
FROM node:9-alpine as node-builder
WORKDIR /src

COPY --from=c-builder /src/aerospike-client-c/target/Linux-x86_64/include/ aerospike-client-c/include/
COPY --from=c-builder /src/aerospike-client-c/target/Linux-x86_64/lib/ aerospike-client-c/lib/

ENV AS_NODEJS_VERSION 3.2.0
ENV PREFIX=/src/aerospike-client-c/

RUN apk update
RUN apk add --no-cache \
      build-base bash python linux-headers zlib-dev
RUN npm install aerospike@${AS_NODEJS_VERSION}

# Stage 3: Aerospike Node.js Runtime
FROM node:9-alpine
WORKDIR /src
COPY --from=node-builder /src/node_modules/ node_modules/

@srfrnk
Copy link
Author

srfrnk commented Mar 6, 2018

That works @jhecking - great solution!

@srfrnk srfrnk closed this as completed Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants