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

Simple meteorJS sample #100

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions samples/golang-mongodb-atlas/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
version: '3.9'
services:
app:
restart: unless-stopped
build:
context: .
context: ./app
dockerfile: Dockerfile
ports:
- mode: ingress
target: 8080
published: 8080
environment:
- MONGO_URI=your mongo db URI connection string

3 changes: 3 additions & 0 deletions samples/meteor/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
.meteor/local
node_modules
1 change: 1 addition & 0 deletions samples/meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
19 changes: 19 additions & 0 deletions samples/meteor/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
1.3.0-split-minifiers-package
1.4.0-remove-old-dev-bundle-link
1.4.1-add-shell-server-package
1.4.3-split-account-service-packages
1.5-add-dynamic-import-package
1.7-split-underscore-from-meteor-base
1.8.3-split-jquery-from-blaze
1 change: 1 addition & 0 deletions samples/meteor/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
7 changes: 7 additions & 0 deletions samples/meteor/.meteor/.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics

llguvii62hi.wevyt9xba2dc
22 changes: 22 additions & 0 deletions samples/meteor/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

[email protected] # Packages every Meteor app needs to have
[email protected] # Packages for a great mobile UX
[email protected] # The database Meteor supports right now
[email protected] # Reactive variable for tracker

[email protected] # CSS minifier run for production mode
[email protected] # JS minifier run for production mode
[email protected] # ECMAScript 5 compatibility for older browsers
[email protected] # Enable ECMAScript2015+ syntax in app code
[email protected] # Enable TypeScript syntax in .ts and .tsx modules
[email protected] # Server-side component of the `meteor shell` command
[email protected] # Update client in development without reloading the page


[email protected] # Define static page content in .html files
react-meteor-data # React higher-order component for reactively tracking Meteor data
2 changes: 2 additions & 0 deletions samples/meteor/.meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
1 change: 1 addition & 0 deletions samples/meteor/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]
71 changes: 71 additions & 0 deletions samples/meteor/.meteor/versions
1 change: 1 addition & 0 deletions samples/meteor/.plandex/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":"08e46c65-a394-4c1c-976e-18e23904217a"}
38 changes: 38 additions & 0 deletions samples/meteor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Use an official Meteor runtime as a parent image
FROM geoffreybooth/meteor-base:latest

# Set the working directory
WORKDIR /app

# Install Node.js
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs

# Copy only the package.json and package-lock.json first
COPY package*.json ./

# Install Node.js dependencies
RUN meteor npm install
RUN meteor npm install --save @babel/runtime

# Copy the rest of the application
COPY . .

# Set METEOR_ALLOW_SUPERUSER to avoid permission issues
ENV METEOR_ALLOW_SUPERUSER=true

# Build the Meteor app
RUN meteor build --directory /app/build --server-only

# Change to the server bundle directory and install server dependencies
WORKDIR /app/build/bundle/programs/server
RUN npm install

# Change back to the app directory
WORKDIR /app

# Expose the port the app runs on
EXPOSE 3000

# Define the command to run the app
CMD ["node", "/app/build/bundle/main.js"]
42 changes: 42 additions & 0 deletions samples/meteor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Meteor Application with Docker

This sample project demonstrates how to deploy a Meteor application using Docker and connect it to a MongoDB database. We also demonstrate how to run a MongoDB container during development and how to switch over to a managed MongoDB service in production.

## Prerequisites

1. Download [Defang CLI](https://github.com/DefangLabs/defang)
2. Have a managed MongoDB service configured and have the connection string ready.
3. (Optional) If you are using [Defang BYOC](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) authenticated with your AWS account
4. (Optional - for local development) [Docker CLI](https://docs.docker.com/engine/install/)
5. (Optional - for local development) [Meteor CLI](https://docs.meteor.com/install.html)

### Editing the database/permissions etc.

If you want to edit the database, permissions, or any other Meteor settings such that you can deploy them to production, you should make those changes locally and test them in the development environment. Once satisfied, these changes can be applied to the production environment.

## Deploying

1. Open the terminal and type `defang login`
2. Add your connection string as a defang config value by typing `defang config set MONGO_URL` and pasting your connection string (which should be in the format `mongodb://username:password@host:port/dbname`)
3. Set up the environment variables `MONGO_URL` and `ROOT_URL` by typing in `defang config set MONGO_URL` and `defang config set ROOT_URL`
4. Type `defang compose up` in the CLI. 5. Your app will be running within a few minutes.

## Development

For development, we use a MongoDB container. The MongoDB container is defined in the `compose.dev.yaml` file. The Meteor container is also defined in the `compose.dev.yaml` file so it can correctly connect to the development database container.

To start the development environment, run

`docker-compose up --build`.

This will start the MongoDB container and the Meteor container. The Meteor application will be available at `http://localhost:3000`.

---

Title: Meteor

Short Description: A sample project demonstrating how to deploy a Meteor application using Docker and connect it to a MongoDB database

Tags: meteor, mongodb

Languages: javascript, mongodb
9 changes: 9 additions & 0 deletions samples/meteor/client/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<head>
<title>Defang x Meteor</title>
</head>

<body>
<h1>Defang x Meteor</h1>
<div id="render-target"></div>
</body>

13 changes: 13 additions & 0 deletions samples/meteor/client/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Meteor } from 'meteor/meteor';
import { render } from 'react-dom';
import React from 'react';

const App = () => (
<div>
<h1>Defang x Meteor</h1>
</div>
);

Meteor.startup(() => {
render(<App />, document.getElementById('render-target'));
});
28 changes: 28 additions & 0 deletions samples/meteor/compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3.8"

services:
meteor-app:
build: .
ports:
- target: 3000
published: 3000
protocol: tcp
mode: ingress
environment:
MONGO_URL: mongodb://mongo:27017/meteor
ROOT_URL: http://localhost:3000
PORT: 3000
depends_on:
- mongo

mongo:
image: mongo:latest
ports:
- target: 27017
published: 27017
protocol: tcp
mode: host
volumes:
- mongo-data:/data/db
volumes:
mongo-data:
16 changes: 16 additions & 0 deletions samples/meteor/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.8"

services:
meteor:
build: .
container_name: meteor
platform: linux/amd64
environment:
- MONGO_URL # your MONGODB URL
- ROOT_URL # your ROOT URL
- PORT=3000
ports:
- target: 3000
published: 3000
protocol: tcp
mode: ingress
Loading
Loading