Search code examples
dockermeteordockerfile

How to setup a older meteor version in dockerfile, and docker container


I have a project running with meteor and node.js in my local. The meteor version is 2.4, node.js version is 8.9.4, I have meteor/release file to make meteor version be 2.2 so that meteor and node can work together.

(base) xxx$ meteor --version
Meteor 2.4
(base) xxx$ node -v
v8.9.4

enter image description here

It seems fine so I deploy this project to docker container to server. The Dockerfile first line I wrote

# node version dependent on meteor version
FROM node:8.9.4

After successfully deployed, the docker logs shows error siad.

Waiting for mongodb server to start - sleeping
warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info:    Forever processing file: /app/bundle/main.js
error:   undefined
data:    /app/bundle/main.js:34 - Meteor requires Node v12.0.0 or later.
data:    /app/bundle/main.js:34 - error: Forever detected script exited with code: 1

I check inside docker, the node version is 8.9.4

(base) [xxx]$  docker exec -it -u root tblbuilder_meteor_1 /bin/bash -c 'node --version'
v8.9.4

So I assume it is meteor version. But first I dont know how to check meteor version inside the docker. And second why this happens? I am sure the release file is updated to push project folder.

With some great man help, I kinda understand it. In local I use meteor 2.2, in docker file I use node.js 8.9.4 work with meteor2.2. So the thing I left is to modify DOCKERFILE, change it from node 8.9.4 to node 12. Below is my Dockerfile file, I try to change it to node 12.22.2, but it keep give me error, I spent one day to solve them. Currently, I stack at install r-base part. Is there some guide for change node 8 to node 12.

# node version dependent on meteor version
FROM node:8.9.4
# I am going to use 12.22.2
#FROM node:12.22.2

# (even if copied as root you still need to change)
# https://github.com/moby/moby/issues/6119
COPY ./compose/meteor/entrypoint.sh /entrypoint.sh
COPY ./compose/meteor/run_app.sh /run_app.sh
COPY ./compose/meteor/r-cran.pgp /r-cran.pgp
COPY ./settings/settings.json /app/settings.json
COPY ./requirements.txt /requirements.txt
COPY ./r_requirements.sh /r_requirements.sh

# set locale to utf8: https://github.com/docker-library/docs/pull/703/files
# added [check-valid-until=no] & Acquire::Check-Valid-Until "false"; https://unix.stackexchange.com/questions/508724/failed-to-fetch-jessie-backports-repository
# Needs work to bring it up-to-date
RUN \
    echo "deb [check-valid-until=no] http://archive.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list && \
    sed -i '/deb http:\/\/deb.debian.org\/debian jessie-updates main/d' /etc/apt/sources.list && \
    apt-get -o Acquire::Check-Valid-Until=false update && \
    \
    sh -c 'echo "deb [check-valid-until=no] http://cran.rstudio.com/bin/linux/debian jessie-cran35/" >> /etc/apt/sources.list' && \
    apt-key add /r-cran.pgp && \
    \
    apt-get -o Acquire::Check-Valid-Until=false update && \
    apt-get -o Acquire::Check-Valid-Until=false install -y locales && \
    \
    localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \
    export LC_ALL=en_US.UTF-8 && \
    export LANG=en_US.UTF-8 && \
    export LANGUAGE=en_US.UTF-8

ENV LANG en_US.utf8
ENV LC_ALL en_US.UTF-8

# add rstudio debian install for R (requires version >3.3)
# https://cran.r-project.org/bin/linux/debian/
# install R from apt-get
# install python 3.6 from source :/

RUN apt install -y --force-yes r-base-core r-recommended r-base-html r-base-core

RUN apt-get install -y --force-yes wget bsdtar r-base r-base-dev && \
    apt-get clean && \
    \
    wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz && \
    tar zxf Python-3.6.5.tgz && \
    cd ./Python-3.6.5 && \
    ./configure && \
    make && \
    make altinstall && \
    cd .. && \
    rm Python-3.6.5.tgz && \
    rm -rf ./Python-3.6.5

# create paths and users
# change executable permissions
RUN npm install forever -g && \
    \
    mkdir -p /app/production && \
    mkdir -p /app/logs && \
    mkdir -p /app/crons && \
    \
    groupadd -r app && \
    useradd -m -d /home/app -g app app && \
    \
    chmod +x /entrypoint.sh && \
    chmod +x /run_app.sh && \
    chmod +x /r_requirements.sh && \
    chmod +x /requirements.txt && \

    \
    chown -R app:app /app && \
    chown app:app /entrypoint.sh && \
    chown app:app /run_app.sh && \
    chown app:app /r_requirements.sh &&\
    chown app:app /requirements.txt

USER app

# 1) install R packages
# 2) install python packages
RUN export "R_LIBS=/home/app/R_libs" && \
    mkdir /home/app/R_libs && \
    bash /r_requirements.sh && \
    \
    /usr/local/bin/pip3.6 install --user -r /requirements.txt

USER root
COPY ./compose/meteor/src/src.tar.gz /app/src.tar.gz
COPY ./src/private /app/src/private
RUN chown -R app:app /app

USER app
RUN cd /app && \
    bsdtar -xzvf src.tar.gz && \
    npm install --prefix /app/bundle/programs/server --production

ENTRYPOINT ["/entrypoint.sh"]


Solution

  • There are many wrong understanding in your tests:

    1. Your Meteor version is 2.2, because is the version inside your project;
    2. To you see the Node version of this Meteor project, see this answers that many guys send to you in Meteor Docker Node.js version is not match
    3. Usually, we build the Meteor, that mean transform it in a NodeJS package build, then, inside of the Docker you don't need Meteor.
    4. We need see your Dockerfile and understand what process you do to build do Docker image.