Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development environment? #48

Closed
tomcardoso opened this issue Jun 1, 2020 · 6 comments
Closed

Development environment? #48

tomcardoso opened this issue Jun 1, 2020 · 6 comments

Comments

@tomcardoso
Copy link

Hi there, thanks for this repo, it's super helpful. I've a quick question. From reading the docs, it looks like this project is really geared at deploying a containerized Meteor instance — so things will get minified, etc. Is there a version of the sample Dockerfile that doesn't do latter build steps and just stands up an instance I can use during development? If not, I'll roll my own, but wanted to make sure I wasn't wasting my time if something like this already exists!

@GeoffreyBooth
Copy link
Collaborator

There isn't, because it would be a very different structure: you'd want to map in your source files so that it rebuilds on save, you'd want to map in all node_modules folders so that they're cached, etc. The result would probably be slower than the regular meteor command.

If you build one and it seems to work well, please share!

@tomcardoso
Copy link
Author

FWIW, I may have an image I can share soon on this, if you're interested. It does take a while to boot up, but works pretty well for development after that.

@GeoffreyBooth
Copy link
Collaborator

Yes please!

@tomcardoso
Copy link
Author

My files:
https://github.com/globeandmail/chart-tool/blob/dockerization/docker-compose.yml
https://github.com/globeandmail/chart-tool/blob/dockerization/docker/dev.Dockerfile

This app is a bit unusual in that it's actually two things in one: a Meteor-driven interface and a charting library (hence the exposing of two ports — one for building out the library using Gulp, Browsersync, etc., and another for the interface). But that lays out the rough structure. It works for me right now. Like I said, boot-up takes a bit (Meteor has to do all the package finding and installing stuff), but it works pretty well after that, though I did have to increase my Docker memory size a bit (to 4096mb).

I'll probably end up adding an additional flag, for --exclude-archs "web.browser.legacy, web.cordova" since we don't really care about non-Linux architectures anymore and it'll speed up performance a bit.

@enzolutions
Copy link

The Dockerfile path changed and now is https://github.com/globeandmail/chart-tool/blob/dockerization/Dockerfile.dev

@enzolutions
Copy link

Hi @tomcardoso

I am wondering if you continue with the idea of the repo to dockerize a meteor app for devel?

I tried to use the configuration you mentioned with some little changes

  • s/chart-tool/keeptrack
  • Update Meteor and Node versions.
  • My Application is located at root level so I removed the /app references

In addition, I have to comment out the section related to gulp

RUN npm ci --unsafe-perm && \
  npm rebuild node-sass

After the build, I got the three containers, but the app doesn't have a port, and when I try to access http://localhost:3000 doesn't work and the status is exited.

The logs show this

browserless_1  | 2020-07-08T07:20:11.812Z browserless:server {
browserless_1  |   CONNECTION_TIMEOUT: 60000,
browserless_1  |   MAX_CONCURRENT_SESSIONS: 10,
browserless_1  |   QUEUE_LENGTH: 10,
browserless_1  |   SINGLE_RUN: false,
browserless_1  |   CHROME_REFRESH_TIME: 1800000,
browserless_1  |   KEEP_ALIVE: false,
browserless_1  |   DEFAULT_BLOCK_ADS: false,
browserless_1  |   DEFAULT_HEADLESS: true,
browserless_1  |   DEFAULT_LAUNCH_ARGS: [],
browserless_1  |   DEFAULT_IGNORE_DEFAULT_ARGS: false,
browserless_1  |   DEFAULT_IGNORE_HTTPS_ERRORS: false,
browserless_1  |   DEFAULT_USER_DATA_DIR: undefined,
browserless_1  |   PREBOOT_CHROME: false,
browserless_1  |   DEBUG: 'browserless*',
browserless_1  |   DEMO_MODE: false,
browserless_1  |   DISABLED_FEATURES: [],
browserless_1  |   ENABLE_CORS: false,
browserless_1  |   ENABLE_API_GET: false,
browserless_1  |   TOKEN: null,
browserless_1  |   DISABLE_AUTO_SET_DOWNLOAD_BEHAVIOR: false,
browserless_1  |   FUNCTION_BUILT_INS: [ 'url' ],
browserless_1  |   FUNCTION_ENABLE_INCOGNITO_MODE: false,
browserless_1  |   FUNCTION_EXTERNALS: [ 'lighthouse', 'node-pdftk', 'sharp' ],
browserless_1  |   WORKSPACE_DIR: '/usr/src/app/workspace',
browserless_1  |   WORKSPACE_DELETE_EXPIRED: false,
browserless_1  |   WORKSPACE_EXPIRE_DAYS: 30,
browserless_1  |   FAILED_HEALTH_URL: null,
browserless_1  |   QUEUE_ALERT_URL: null,
browserless_1  |   REJECT_ALERT_URL: null,
browserless_1  |   TIMEOUT_ALERT_URL: null,
browserless_1  |   ERROR_ALERT_URL: null,
browserless_1  |   EXIT_ON_HEALTH_FAILURE: false,
browserless_1  |   MAX_CPU_PERCENT: 99,
browserless_1  |   MAX_MEMORY_PERCENT: 99,
browserless_1  |   METRICS_JSON_PATH: null,
browserless_1  |   HOST: '0.0.0.0',
browserless_1  |   PORT: 3000,
browserless_1  |   PROXY_HOST: undefined,
browserless_1  |   PROXY_PORT: undefined,
browserless_1  |   PROXY_SSL: false,
browserless_1  |   MAX_PAYLOAD_SIZE: '5mb'
browserless_1  | } Final configuration
keeptrack_app_1 exited with code 1

The app works in production with MUP (http://meteor-up.com/), so maybe is not the code.

CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                      PORTS               NAMES
f6c4384e414a        keeptrack_app               "docker-entrypoint.s…"   12 minutes ago      Exited (1) 12 minutes ago                       keeptrack_app_1
b2110d31df3d        mongo:latest                "docker-entrypoint.s…"   12 minutes ago      Up 12 minutes               27017/tcp           keeptrack_mongo_1
e91244de311c        browserless/chrome:latest   "./start.sh"             12 minutes ago      Up 12 minutes               3000/tcp            keeptrack_browserless_1

Thanks in advance for any ideas about how to fix this.

Configuration files:

DockerFile

# In dev environment, we expect to keep running gulp to build Chart Tool library
# JS/CSS files, and then Docker will watch those changes occur in the folder and
# reflect them in our containerized instance.

# Borrowing from https://github.com/disney/meteor-base/ and https://github.com/staeke/meteor-alpine/

# 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.3-alpine

# Setup environment variables that will be available to the instance
ENV METEOR_VERSION 1.9.3

RUN apk add --update --no-cache bash

# Here we're running https://github.com/staeke/meteor-alpine/ with a few tweaks
RUN export TEMP_PACKAGES="alpine-sdk libc6-compat python linux-headers" && \
    apk add --update --no-cache $TEMP_PACKAGES && \
    curl https://install.meteor.com/?release=${METEOR_VERSION} | sh && \
    cd /root/.meteor/packages/meteor-tool/*/mt-os.linux.x86_64 && \
    cp scripts/admin/launch-meteor /usr/bin/meteor && \
    cd dev_bundle && \
    cd bin && \
    rm node && \
    rm npm && \
    rm npx && \
    ln -s $(which node) && \
    ln -s $(which npm) && \
    ln -s $(which npx) && \
    cd ../mongodb/bin && \
    rm mongo mongod && \
    cd ../../lib && \
    npm rebuild && \
    cd ~ && \
    ln -s /root/.meteor && \
    apk del $TEMP_PACKAGES

ENV APP_HOME /keeptrack

# Create a directory for our application
# and set it as the working directory
RUN mkdir $APP_HOME
RUN mkdir $APP_HOME/.meteor

WORKDIR $APP_HOME

# Copy app and meteor package.json and package-lock.json into container
COPY package*.json $APP_HOME/

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1

# Fix permissions warning; https://github.com/meteor/meteor/issues/7959
ENV METEOR_ALLOW_SUPERUSER=1

# Install gulp so we can run our servers, then npm install
# everything and rebuild node-sass
#RUN npm ci --unsafe-perm && \
#  npm rebuild node-sass

COPY . $APP_HOME

EXPOSE 3000
EXPOSE 3030

CMD ["/bin/sh" , "-c" , "meteor --no-release-check --exclude-archs 'web.browser.legacy, web.cordova'"]

DockerCompose file

version: '3'
services:
  app:
    volumes:
      - ./:/keeptrack
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - '3000:3000'
      - '3030:3030'
    depends_on:
      - mongo
      - browserless
    environment:
      NODE_ENV: development
      MONGO_URL: mongodb://mongo:27017/meteor
      MAIL_URL: smtp://user:password@mailhost:port/
      DOCKER: 'TRUE'
      PORT: 3000
      ROOT_URL: http://app
      CHROME_REMOTE_URL: ws://browserless:3000
    networks:
      - keeptrack-network
  mongo:
    image: mongo:latest
    command:
      - --storageEngine=wiredTiger
      - --logpath=/dev/null
    volumes:
      - data:/data/db
    networks:
      - keeptrack-network
  browserless:
    image: browserless/chrome:latest
    networks:
      - keeptrack-network
    restart: always
networks:
  keeptrack-network:
volumes:
  data:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants