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

Add .meteor/local to dockerignore template #93

Closed
wants to merge 5 commits into from
Closed
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
11 changes: 11 additions & 0 deletions gdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ export class GDF {
this.#pj.devDependencies?.prisma)
}

get meteor() {
return !!this.#pj.dependencies?.['meteor-node-stubs']
}

// Does this application use next.js?
get nextjs() {
return !!this.#pj.dependencies?.next
Expand Down Expand Up @@ -259,6 +263,10 @@ export class GDF {
packages.push('node-gyp')
}

if (this.meteor) {
packages.push('python3-pip', 'g++', 'make', 'curl')
}

// https://docs.npmjs.com/cli/v10/configuring-npm/package-json#git-urls-as-dependencies
if (Object.values(this.#pj.dependencies || {}).some(value => /^git(\+|:|hub:)|^\w+\//.test(value))) {
packages.push('git')
Expand Down Expand Up @@ -718,6 +726,7 @@ export class GDF {
if (this.vite) runtime = 'Vite'
if (this.bunVersion) runtime = 'Bun'
if (this.remix) runtime = 'Remix'
if (this.meteor) runtime = 'Meteor'
if (this.nextjs) runtime = 'Next.js'
if (this.nuxtjs) runtime = 'Nuxt'
if (this.nestjs) runtime = 'NestJS'
Expand Down Expand Up @@ -756,6 +765,8 @@ export class GDF {
return ['node', '/app/build/server.js']
} else if (this.nuxtjs) {
return ['node', '.output/server/index.mjs']
} else if (this.meteor) {
return ['node', 'main.js']
} else if (this.gatsby) {
return [this.npx, 'gatsby', 'serve', '-H', '0.0.0.0']
} else if (this.vite || this.astroStatic) {
Expand Down
4 changes: 4 additions & 0 deletions templates/.dockerignore.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ fly.toml
/build
/public/build
<% } -%>

<% if (meteor) { -%>
/.meteor/local
<% } -%>
22 changes: 22 additions & 0 deletions templates/Dockerfile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,22 @@ RUN <% if (options.cache) { %><%= pkg_cache %>
<% } %><%= pkg_update %> && \
<%= pkg_install %> <%= buildPackages.join(' ') %>

<% if (meteor) { -%>
# Copy the .meteor/release file to the container
COPY .meteor/release /home/meteor/.meteor/release

ENV METEOR_ALLOW_SUPERUSER=1

# Extract the Meteor release version and install Meteor
RUN RELEASE=$(awk -F'@' '{print $2}' /home/meteor/.meteor/release) && curl https://install.meteor.com/\?release\=$RELEASE | sh
<% } -%>
# Install node modules
COPY<% if (options.link) { %> --link<% } %> <%= packageFiles.join(' ') %> ./
RUN <%- buildCache %><%= packagerInstall %>

<% if (meteor) { -%>
RUN meteor npm install
<% } -%>
<% if (prisma) { -%>
# Generate Prisma Client
COPY<% if (options.link) { %> --link<% } %> prisma .
Expand All @@ -84,6 +96,14 @@ RUN <%= npx %> prisma generate
<% } -%>
# Copy application code
COPY<% if (options.link) { %> --link<% } %> . .
<% if (meteor) { -%>
RUN meteor build --server-only --directory bundle

# https://github.com/meteor/meteor/issues/12932
RUN chmod 777 bundle/bundle/programs/server/npm-shrinkwrap.json

RUN cd bundle/bundle/programs/server && meteor npm install
<% } -%>

<% if (build && !options.deferBuild) { -%>
# Build application
Expand Down Expand Up @@ -144,6 +164,8 @@ ENV HOST=0.0.0.0
COPY --from=build /app/build /app/build
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/package.json /app
<% } else if (meteor) { -%>
COPY --from=build /app/bundle/bundle /app
<% } else if (standaloneNextjs) { -%>
COPY --from=build /app/.next/standalone /app
COPY --from=build /app/.next/static /app/.next/static
Expand Down
7 changes: 7 additions & 0 deletions test/frameworks/meteor/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.git
/node_modules
.dockerignore
.env
Dockerfile
fly.toml
.meteor/local
1 change: 1 addition & 0 deletions test/frameworks/meteor/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]
53 changes: 53 additions & 0 deletions test/frameworks/meteor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=xxx
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Meteor"

# Meteor app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential curl g++ make node-gyp pkg-config python-is-python3 python3-pip

# Copy the .meteor/release file to the container
COPY .meteor/release /home/meteor/.meteor/release

ENV METEOR_ALLOW_SUPERUSER=1

# Extract the Meteor release version and install Meteor
RUN RELEASE=$(awk -F'@' '{print $2}' /home/meteor/.meteor/release) && curl https://install.meteor.com/\?release\=$RELEASE | sh
# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci

RUN meteor npm install
# Copy application code
COPY --link . .
RUN meteor build --server-only --directory bundle

# https://github.com/meteor/meteor/issues/12932
RUN chmod 777 bundle/bundle/programs/server/npm-shrinkwrap.json

RUN cd bundle/bundle/programs/server && meteor npm install


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app/bundle/bundle /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "node", "main.js" ]
Loading
Loading