I'm doing my unit tests in a docker container (for my CI workflow)
.
Therefore I've build an image based on ubuntu with nodeJS (4.x) and meteorJS (1.5).
I have to add an ubuntu user, as root user makes some problems with meteor and
I have to set locale to fix the known problem with mongoDB.
In the result the image has 2 GB!!! which is unbelievable for me. It's way too much for just doing some unit tests.
I also tried to to use an alpine version (node:4.8-alpine), but with that I don't get meteor test running
My command to run the unit tests in my CI setting:
TEST_CLIENT=0 meteor test --once --driver-package dispatch:mocha --allow-superuser
And this is the Dockerfile I am using:
FROM ubuntu:16.04
COPY package.json ./
RUN apt-get update -y && \
apt-get install -yqq \
python \
build-essential \
apt-transport-https \
ca-certificates \
curl \
locales \
nodejs \
npm \
nodejs-legacy \
sudo \
git && \
rm -rf /var/lib/apt/lists/*
## NodeJS and MeteorJS
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash -
RUN curl https://install.meteor.com/ | sh
## Dependencies
RUN npm install -g eslint eslint-plugin-react
RUN npm install -g standard
RUN npm install
## Locale
ENV OS_LOCALE="en_US.UTF-8"
RUN locale-gen ${OS_LOCALE}
ENV LANG=${OS_LOCALE} LANGUAGE=en_US:en LC_ALL=${OS_LOCALE}
## User
RUN useradd ubuntu && \
usermod -aG sudo ubuntu && \
mkdir -p /builds/project/testing/.meteor /home/ubuntu && \
chown -Rh ubuntu:ubuntu /builds/project/testing/.meteor && \
chown -Rh ubuntu:ubuntu /home/ubuntu
USER ubuntu
## Initialize meteor
RUN cd /builds/project/testing/ && meteor update --release 1.5
Maybe someone has an idea how to optimize this Dockerfile...
If you're not attached to your version of doing things, feel free to take a look at how I did it: https://hub.docker.com/r/simonsimcity/bitbucket-meteor/tags
Mine is about 300MB - and could be improved as well, I think.
I've based another docker image on it which you can use without changes in Bitbucket, where can do UI testing in Firefox and Chrome: https://hub.docker.com/r/simonsimcity/bitbucket-meteor-headless-browsers
Feel free to extend the idea as you want, it's licensed on MIT.
Related
I am pretty new to Docker and I want to dockerize my react app, the index.html file is under my public folder in the react project. When I run the docker image, it fails and gives me an error stating that the index.html file is missing.
The error:
flash#0.1.0 start
react-scripts start
Could not find a required file. Name: index.html Searched in:
/app/public npm notice npm notice New minor version of npm available!
8.11.0 -> 8.19.2 npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.19.2 npm notice Run npm install -g npm#8.19.2 to update! npm notice
Below is the code of my Dockerfile:
FROM node:lts-alpine3.14 as build
RUN apk update && \
apk upgrade && \
apk add --no-cache bash git openssh
RUN mkdir /app
WORKDIR /app
COPY package.json .
RUN npm install -g --force npm#latest typescript#latest yarn#latest
RUN npm install
COPY . ./
RUN npm run build
# ---------------
FROM node:lts-alpine3.14
RUN mkdir -p /app/build
RUN apk update && \
apk upgrade && \
apk add git
WORKDIR /app
COPY --from=build /app/package.json .
RUN yarn install --production
COPY --from=build . .
EXPOSE 3000
EXPOSE 3001
ENV SERVER_PORT=3000
ENV API_PORT=3001
ENV NODE_ENV production
CMD ["npm", "start"]
Try to attach the shell to the container with
docker exec -it CONTAINER_NAME bash
and see where is index.html file and where you need to copy it
I installed Raspberry Pi Desktop on an old laptop and then I installed nodejs using 'sudo apt install nodejs'. After that, when I verify the version of node, using 'node -v' or 'nodejs -v' I get 'v10.24.0'.
Then I try upgrade the Nodejs version but it doesn't work because whatever way I used to upgrade, the version stays the same.
I try this:
pi#local-server-raspi:~ $ sudo su -
root#local-server-raspi:~ # apt-get remove nodered -y
root#local-server-raspi:~ # apt-get remove nodejs nodejs-legacy -y
root#local-server-raspi:~ # apt-get remove npm -y
root#local-server-raspi:~ # curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
root#local-server-raspi:~ # apt-get install nodejs -y
root#local-server-raspi:~ # node -v
v10.24.0
root#local-server-raspi:~ # npm -v
bash: npm: command not found
I also try with nvm but with the same result, when I type 'nodejs -v' I get 'no such file or directory' and when I type 'node -v' I get the same version, 10.24.0.
I appreciate it if any of you have some idea how to upgrade the version of the nodejs to the LTS version, 14.16.1.
I had the same problem while trying to install nodejs to the raspberrypi 4. I needed a newer version to run yarn. There are many tutorials but this instruction video (below) fixed my problem and upgraded the nodejs to 14.16.1. (Thanks Dave!!!)
thisdavej.com/upgrading-to-more-recent-versions-of-node-js-on-the-raspberry-pi/
I had the same problem on Raspberry Pi3. I tried all sorts of things and this is what finally worked...
node -v
v10.24.0
# Remove...
sudo apt remove node
sudo apt remove nodejs
# Install...
sudo curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
# Check
node -v && npm -v
v14.19.3
6.14.17
The title may be a bit weird and misleading, basically what I want to do is:
I need a node.js server that runs the following script from the dockerfile below. I don't want to run docker inside docker, so I need to combine the script and nodejs server, but don't know how, since I'm quite new to docker.
Should I add a configuration for the node js environment in the dockerfile below, or create a new dockerfile that depends on this one? And what should I do? Nevertheless, how do I do it?
FROM leon/usd:latest
WORKDIR /usr/src/ufg
# Configuration
ARG UFG_RELEASE="3bf441e0eb5b6cfbe487bbf1e2b42b7447c43d02"
ARG UFG_SRC="/usr/src/ufg"
ARG UFG_INSTALL="/usr/local/ufg"
ENV USD_DIR="/usr/local/usd"
ENV LD_LIBRARY_PATH="${USD_DIR}/lib:${UFG_SRC}/lib"
ENV PATH="${PATH}:${UFG_INSTALL}/bin"
ENV PYTHONPATH="${PYTHONPATH}:${UFG_INSTALL}/python"
# Build + install usd_from_gltf
RUN git init && \
git remote add origin https://github.com/google/usd_from_gltf.git && \
git fetch --depth 1 origin "${UFG_RELEASE}" && \
git checkout FETCH_HEAD && \
python "${UFG_SRC}/tools/ufginstall/ufginstall.py" -v "${UFG_INSTALL}" "${USD_DIR}" && \
cp -r "${UFG_SRC}/tools/ufgbatch" "${UFG_INSTALL}/python" && \
rm -rf "${UFG_SRC}" "${UFG_INSTALL}/build" "${UFG_INSTALL}/src"
RUN mkdir /usr/app
WORKDIR /usr/app
# Start the service
ENTRYPOINT ["usd_from_gltf"]
CMD ["usd_from_gltf"]
In Node's case, you can basically just splat in the instructions to download the Node.js tarball and unpack it in place. This is based on the official Node dockerfile which does some more authenticity checking, etc.
RUN \
cd /tmp \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v13.12.0/node-v13.12.0-linux-x64.tar.xz" \
&& tar -xJf "node-v13.12.0-linux-x64.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v13.12.0-linux-x64.tar.xz" \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
If you also need the Yarn package manager, the instructions for adding it are in that same linked dockerfile.
Another option, since it looks like leon/usd is using a Debian/Ubuntu base image, is to just install Node.js using the image's Linux distribution's package manager, e.g. RUN apt-get update && apt-get install nodejs.
I'm trying to run Telescope (a meteor app) on an Ubuntu 16.04 server. I follow the instructions in the readme:
curl https://install.meteor.com/ | sh
git clone git#github.com:TelescopeJS/Telescope.git
npm install
The first two commands run without an error, but the last command end in Killed:
$ npm install
npm WARN deprecated cross-spawn-async#2.2.4: cross-spawn no longer requires a build toolchain, use it instead!
extract:moment → gunzTarP ▐ ╢█████████████████████████████████████████████████░░░░░░░░░░╟
Killed
Since it doesn't give any information I'm unsure what could be wrong here. Does anybody know how I can solve this? All tips are welcome!
[EDIT]
Using the tip of #Mills in the comments I first ran npm install cross-spawn and then npm install again. This fixed the npm install issue, but when I now try to run the app using meteor it ends with "Killed" again:
$ meteor
Killednloading meteor-tool#1.3.2_4... |
Any more ideas?
I haved same problem, my solution:
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
this commands changed configuration for swap
I am running into a similar issue installing npm packages and getting the message "Killed" and a non-zero exit status. For my scenario, it was because my system was running out of memory and I had no swap configured. Configuring swap fixed my problem.
To solve this issue on 14.04 and 16.04:
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo sysctl vm.swappiness=10
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl vm.vfs_cache_pressure=50
echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf
This will create a swap file of 1GB
Trying running npm install cross-spawn and then npm install again to see if that works. It looks like whats happening is when you run npm install npm looks inside your package.json provided by telesope and is running a deprecated package
I got the same issue when running npm run build in a VM with a single core CPU and 1GB RAM. Increasing the RAM to 4GB resolved this issue.
or you can do the hardway do npm install somewhere else. i did it on my windows and uploaded al the nodemodules dir with ftpclient to the server. that worked for me
I got the same error on DO. I just increased size of CPU and RAM
I am trying to install meteor using : curl https://install.meteor.com | /bin/sh
command on terminal but it gives me following error:
The program 'curl' is currently not installed. You can install it by typing:
sudo apt-get install curl
And when I tried installing curl by command : sudo apt-get install curl
Following error is shown to me:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package curl is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'curl' has no installation candidate
Can anyone please tell me how to resolve this issue.
See this post on askubuntu.
sudo sed -i -e 's/us.archive.ubuntu.com/archive.ubuntu.com/g' /etc/apt/sources.list
sudo apt-get update
sudo apt-get install curl
hook up to the best server from the software & updates section
then
sudo apt-get update
sudo apt-get install curl