npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lbdudc/gp-code-uploader

v1.1.2

Published

Code Uploader is a flexible library that simplifies uploading code to a server and executing it via docker-compose. This module offers various code distribution options for SSH-based servers, AWS instances, and local installations.

Downloads

5

Readme

Code Uploader

GitHub license Node.js Version npm version

Description

The Code Uploader is a versatile library designed to simplify the process of uploading code to a server and executing it via docker-compose. This library provides flexible strategies to facilitate code deployment across different environments, such as SSH-based servers, AWS instances, and local setups.

Installation

Install the package via npm:

npm install @lbdudc/gp-code-uploader

Pre-requisites

  • Have installed in your machine:

  • Must be a root user or have sudo privileges in the server where you want to upload the code

Known Issues :warning:

In AWS instances, the docker-compose up command can fail with the basic EC2 free tier instance. This is because the instance does not have enough memory to run the docker-compose up command. To solve this, you can use a bigger instance

Example Usages

More examples can be found in the ./examples folder.

SSH (Debian/Ubuntu)

SSH Usage Example

import { Uploader, DebianUploadStrategy } from '@lbdudc/gp-code-uploader';

const uploader = new Uploader();
uploader.setUploadStrategy(new DebianUploadStrategy());

const config = {
    host: '127.0.0.1',
    port: 22,
    username: 'root',
    certRoute: '/home/certs/id_rsa', // Optional but recommended
    repoPath: 'code/lps/output',
    remoteRepoPath: '/home/username/code',
    forceBuild: true, // default false
};

// Upload code, configure the instance and run docker-compose up
await uploader.uploadCode(config);

AWS

import { Uploader, AWSUploadStrategy } from '@lbdudc/gp-code-uploader';

// Create the uploader
const uploader = new Uploader();

// Set the upload strategy
uploader.setUploadStrategy(new AWSUploadStrategy());

// Create AWS instance
const hostIp = await uploader.createInstance({
    AWS_SECRET_ACCESS_KEY: '',
    AWS_REGION: 'eu-west-2',
    AWS_AMI_ID: 'ami-08b064b1296caf3b2',
    AWS_INSTANCE_TYPE: 't2.micro',
    AWS_INSTANCE_NAME: 'my-aws-instance',
    AWS_SECURITY_GROUP_ID: 'sg-xxxxxxxxxxxxxxxxx',
    AWS_KEY_NAME: 'my-key-pair',
    AWS_USERNAME: 'ec2-user',
    AWS_SSH_PRIVATE_KEY_PATH:'./my-key-pair.pem',
    AWS_ACCESS_KEY_ID: '',
});

// Upload code by SCP, configure instance, and run docker-compose up
await uploader.uploadCode({
    host: hostIp,
    username: 'ec2-user',
    certRoute: './my-key-pair.pem',
    awsRegion: 'eu-west-2',
    repoPath: '../code',
    remoteRepoPath: `/home/ec2-user/code`,
    // forceBuild: true,
});

Methods

uploader.js exposes the following methods:

  • uploadCode(options): Promise<UploadCodeResponse>: Uploads the code, configures the instance and runs docker-compose up

AWS Instance Pre-requisites

You need to create an AWS instance with the following:

  • An SSH key pair guide
  • A security group with the following inbound rules: guide
    • SSH (port 22) from your IP (or the IP of the server you want to access the instance from)
    • HTTP (port 80) from your IP (or the IP of the server you want to access the instance from)
  • A security group with the following outboud rules: guide
    • All traffic (all ports) to your IP (or the IP of the server you want to access the instance from)
  • An IAM role with the following permissions: guide
    • AmazonEC2FullAccess
  • Get your AWS access key and secret key: guide

Dependencies

  • @aws-sdk/client-ec2: ^3.32.0
  • dotenv: ^16.0.3
  • jszip: ^3.10.1

Dev Dependencies

  • @vitest/coverage-istanbul: ^0.32.2
  • vitest: ^0.32.0

Author

Victor Lamas Email: [email protected]

License

This project is licensed under the MIT License - see the LICENSE.md file for details