From d3ad147d0353a513961db6c500a2a947b2661d62 Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Thu, 23 Jul 2020 20:57:39 +0200 Subject: [PATCH] docker v2 --- .dockerignore | 3 +++ Dockerfile | 53 +++++++++++++++++++++++++++++++--------------- docker-compose.yml | 8 ++++++- 3 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..908be90 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ + +**/node_modules +**/.meteor/local \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5c3c403..660f90c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,40 @@ -FROM node:lts-buster +# The tag here should match the Meteor version of your app, per .meteor/release +FROM geoffreybooth/meteor-base:1.10.2 -ENV MONGO_URL=mongodb://garden:99009911@cloud.timovolkmann.de:27017/Smart_Garden -ENV PORT=3000 +# Copy app package.json and package-lock.json into container +COPY package*.json $APP_SOURCE_FOLDER/ + +RUN bash $SCRIPTS_FOLDER/build-app-npm-dependencies.sh + +# Copy app source into container +COPY . $APP_SOURCE_FOLDER/ + +RUN bash $SCRIPTS_FOLDER/build-meteor-bundle.sh + + +# Use the specific version of Node expected by your Meteor release, per https://docs.meteor.com/changelog.html; this is expected for Meteor 1.10.2 +FROM node:12.16.1-alpine + +ENV APP_BUNDLE_FOLDER /opt/bundle +ENV SCRIPTS_FOLDER /docker ENV NODE_ENV=production - -RUN curl https://install.meteor.com/ | /bin/sh - -WORKDIR /usr/app/smartgarden - -COPY package*.json ./ - -RUN meteor npm install - -COPY . . - -EXPOSE 3000 - -CMD [ "meteor", "--unsafe-perm", "--allow-superuser" ] +ENV METEOR_ALLOW_SUPERUSER=TRUE +# Runtime dependencies; if your dependencies need compilation (native modules such as bcrypt) or you are using Meteor <1.8.1, use app-with-native-dependencies.dockerfile instead +RUN apk --no-cache add \ + bash \ + ca-certificates + +# Copy in entrypoint +COPY --from=0 $SCRIPTS_FOLDER $SCRIPTS_FOLDER/ + +# Copy in app bundle +COPY --from=0 $APP_BUNDLE_FOLDER/bundle $APP_BUNDLE_FOLDER/bundle/ + +RUN bash $SCRIPTS_FOLDER/build-meteor-npm-dependencies.sh + +# Start app +ENTRYPOINT ["/docker/entrypoint.sh"] + +CMD ["node", "main.js"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 32053b4..606e49c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,14 @@ version: "3" services: smartgarden-meteor: image: tvm/smart_garden:latest - build: . + build: + context: . + dockerfile: Dockerfile restart: always + environment: + ROOT_URL: ${APP_ROOT_URL:-https://smartgarden.timovolkmann.de} + MONGO_URL: mongodb://garden:99009911@cloud.timovolkmann.de:27017/Smart_Garden + PORT: 3000 labels: - traefik.enable=true - traefik.http.routers.smartgarden-meteor-http.rule=Host(`smartgarden.timovolkmann.de`)