mfornasa / dockeryarn Goto Github PK
View Code? Open in Web Editor NEWYarn on Docker Boilerplate
Yarn on Docker Boilerplate
Did I misunderstood something... or the "latest.tar.gz" we see in this repository is the Yarn cache referenced as ".yarn-cache.tgz" in the Medium article?
Hey your article on Medium is awesome! Thanks so much for putting that together!
There must be something I'm misunderstanding or not doing right because when I try and deploy my container via docker run ...
it errors out and says "cannot find module".
This is the same build file you're using in the demo minus changing the context to the current folder. (My script lives in $DIR/scripts/build.sh. Dockerfile lives under $DIR/.)
It looks like it's pulling the /tmp/yarn.lock
file from my PERSONAL computer, not the container. Is that supposed to be the case?
I believe the same is taking place with /root/.yarn-cache
Any help you can offer would be great!
When I run ls node_modules
I do see the symlink setup and the node_modules do exist!
Thanks again
./scripts/build.sh
#1/bin/bash
cd "$(dirname "../")"
pwd
touch yarn.lock
# Init empty cache file
if [ ! -f .yarn-cache.tgz ]; then
echo "Init empty .yarn-cache.tgz"
tar cvzf .yarn-cache.tgz --files-from /dev/null
fi
docker build . -t peterpme/testapp
docker run --rm --entrypoint cat peterpme/testapp:latest /tmp/yarn.lock > /tmp/yarn.lock
if ! diff -q yarn.lock /tmp/yarn.lock > /dev/null 2>&1; then
echo "Saving Yarn cache"
docker run --rm --entrypoint tar peterpme/testapp:latest czf - /root/.yarn-cache/ > .yarn-cache.tgz
echo "Saving yarn.lock"
cp /tmp/yarn.lock yarn.lock
fi
./Dockerfile:
FROM risingstack/alpine:3.4-v6.9.1-4.1.0
WORKDIR /opt/app
# Install Yarn
RUN mkdir -p /opt
ADD ./scripts/latest.tar.gz /opt/
RUN mv /opt/dist /opt/yarn
ENV PATH "$PATH:/opt/yarn/bin"
ADD package.json yarn.lock /tmp/
# Copy cache contents
ADD .yarn-cache.tgz /
# Install NPM Packages
RUN cd /tmp && yarn
RUN mkdir -p /opt/app && cd /opt/app && ln -s /tmp/node_modules
# Copy project code over
ADD . /opt/app
# Expose private port
EXPOSE 5000
# Start the project
CMD ["node", "keystone.js"]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.