Closed UglyHobbitFeet closed 4 years ago
FWIW I notice the output above (step 8 of 18) references es4x-pm and not @es4x/create. Dunno if the es4x-pm calls should be removed from the docker stuff and if that's an issue or not. I only have @es4x/create installed on my machine
Also FWIW I'm using Docker version 19.03.13
The docker file downloads the pm tools (same as @es4x/create
) to ensure its always available but probably having it globally + already installed from node is causing trouble.
@pmlopes can you tell me the refactor branch where you did move the install parts to runtime? i am at present lost and do not know where to work on fixes as we goot the require branch that needs merge into upstream asap
All development happens on develop
, master
is the exact code of the latest published release.
@UglyHobbitFeet, there's a bug on the generated Dockerfile
, I'll fix it soon as vert.x 3.9.4 is about to be released so I'll ship it together, in the mean time this should be the dockerfile:
ARG BASEIMAGE=oracle/graalvm-ce:20.2.0
# Use official node for build
FROM node:lts AS NPM
# Create app directory
WORKDIR /usr/src/app
# Add the application to the container
COPY . .
# Install app dependencies
# npm is run with unsafe permissions because the default docker user is root
RUN npm --unsafe-perm ci
# Second stage (build the JVM related code)
FROM $BASEIMAGE AS JVM
ARG ES4X_VERSION=0.13.2
ARG ES4X_OPTS=""
# Download the ES4X runtime tool
RUN curl -sL https://github.com/reactiverse/es4x/releases/download/${ES4X_VERSION}/es4x-pm-${ES4X_VERSION}-bin.tar.gz | tar zx --strip-components=1 -C /usr/local
# force es4x maven resolution only to consider production dependencies
ENV ES4X_ENV=production
# Copy the previous build step
COPY --from=NPM /usr/src/app /usr/src/app
# use the copied workspace
WORKDIR /usr/src/app
# Install the maven dependencies
RUN find .
RUN es4x install $ES4X_OPTS
# Third stage (contain)
FROM $BASEIMAGE
# Collect the jars from the previous step
COPY --from=JVM /usr/src/app /usr/src/app
# use the copied workspace
WORKDIR /usr/src/app
# Bundle app source
COPY . .
# Define custom java options for containers
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:+UseContainerSupport"
# define the entrypoint
ENTRYPOINT [ "./node_modules/.bin/es4x-launcher" ]
Works as expected. Thanks!
On Tue, Oct 13, 2020 at 6:04 AM Paulo Lopes notifications@github.com wrote:
Closed #425 https://github.com/reactiverse/es4x/issues/425 via bf67f36 https://github.com/reactiverse/es4x/commit/bf67f36f906fa78829a60bd343a9d46ee69c5bef .
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/reactiverse/es4x/issues/425#event-3870436694, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALBDS7UGLAT4LZIPBYJN4HLSKQQ4JANCNFSM4SKBHWQQ .
Just curious but it seems like the docker images are fairly high out of the box. I did a bare bones test with 4 small js files and this package.json and when I run a 'docker images' I see my image is 1.21GB. It looks like GraaalVM takes up 900MB of that. Is there an alternative you can recommend or a flag we could pass when doing 'es4x dockerfile' that would toggle between a slim and fat version?
{
"name": "my-test",
"version": "1.0.0",
"private": true,
"main": "index.js",
"dependencies": {
"@vertx/core": "3.9.3",
"@vertx/mongo-client": "^3.9.3",
"@vertx/web": "^3.9.3",
"@vertx/web-client": "^3.9.3"
},
"devDependencies": {
"@es4x/create": "0.13.2"
},
"scripts": {
"postinstall": "es4x install",
"start": "es4x"
}
}
I created an ES4x docker file and tried to build it. It barfs with the following error: ERROR: Service 'my-project' failed to build : The command '/bin/sh -c es4x install -f' returned a non-zero code: 2
If I run that exact same command in a terminal it works fine.
Attached below is my DockerFile, docker build command and command line without docker
DOCKERFILE:
Docker Build File:
CMD LIne (No Docker):