Skip to content

Commit

Permalink
add ignore scripts option
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed May 8, 2023
1 parent e816989 commit d04f23c
Show file tree
Hide file tree
Showing 7 changed files with 5,565 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Options are saved between runs into `package.json`. To invert a boolean options,

### Options:

* `--ignore-scripts` - do not execute any scripts defined in the project `package.json` and its dependencies.
* `--force` - overwrite existing files
* `--legacy-peer-deps` - [ignore peer dependencies](https://docs.npmjs.com/cli/v7/using-npm/config#legacy-peer-deps).
* `--swap=n` - allocate swap space. See [falloc options](https://man7.org/linux/man-pages/man1/fallocate.1.html#OPTIONS) for suffixes
Expand Down
5 changes: 5 additions & 0 deletions gdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ export class GDF {
}
}

// optionally include scripts
if (this.options.ignoreScripts) {
install += ' --ignore-scripts'
}

return install
}

Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { GDF } from './gdf.js'

// defaults for all the flags that will be saved
const defaults = {
ignoreScripts: false,
legacyPeerDeps: false,
swap: '',
windows: false
Expand All @@ -30,6 +31,11 @@ const options = yargs((hideBin(process.argv)))
describe: 'force overwrite of existing files',
type: 'boolean'
})
.option('ignore-scripts', {
alias: 'i',
describe: 'ignore scripts',
type: 'boolean'
})
.option('legacy-peer-deps', {
alias: 'l',
describe: 'ignore peer dependencies',
Expand Down
6 changes: 6 additions & 0 deletions test/ignore-scripts/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.git
/node_modules
.dockerignore
.env
Dockerfile
fly.toml
42 changes: 42 additions & 0 deletions test/ignore-scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# syntax = docker/dockerfile:1.4

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

LABEL fly_launch_runtime="Node.js"

# Node.js 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 -y python-is-python3 pkg-config build-essential

# Install node modules
COPY --link package.json package-lock.json ./
RUN npm ci --include=dev --ignore-scripts

# Copy application code
COPY --link . .

# Remove development dependencies
RUN npm prune --omit=dev


# Final stage for app image
FROM base

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

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npx", "fastify", "start", "--address", "0.0.0.0", "-l", "info", "app.js" ]
Loading

0 comments on commit d04f23c

Please sign in to comment.