GithubHelp home page GithubHelp logo

bonakodo-eric / wallarm-heroku Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 29 KB

Wallarm Base Docker Image for Heroku

License: BSD 3-Clause "New" or "Revised" License

HTML 52.62% Dockerfile 28.12% Shell 15.02% JavaScript 4.23%

wallarm-heroku's Introduction

Wallarm Base Docker Image for Heroku

This repository contains the Dockerfile and necessary resources to build a Wallarm base Docker image for running on Heroku. This image is designed to simplify the deployment process of Wallarm-protected applications on the Heroku platform.

Table of Contents

Prerequisites

Before you begin, ensure you have met the following requirements:

  • You have a Heroku account. If you don't have one, sign up here.
  • You have installed the latest version of Docker.
  • You have installed the Heroku CLI.

Usage

To use the Wallarm base Docker image for your Heroku application, follow these steps:

  1. Create a Dockerfile in the root of your app directory. Install all necessary dependencies such as your app's runtime. For NodeJS, use the following example:
FROM bonakodo/wallarm-heroku:4.10.2

# Install NodeJS v21 from NodeSource
RUN curl -fsSL https://deb.nodesource.com/setup_21.x | bash - \
  && apt-get install nodejs -qqy \
  && apt-get clean

ADD . /opt/webapp
WORKDIR /opt/webapp

# Install production dependencies and build the app, if necessary
RUN npm install --omit=dev && npm run build
ENV npm_config_prefix /opt/webapp

# Note that in private spaces the `run` section of heroku.yml is ignored
# See: https://devcenter.heroku.com/articles/build-docker-images-heroku-yml#known-issues-and-limitations
CMD ["npm", "run", "start"]
  1. Create a heroku.yml configuration file as follows:
# heroku.yml
build:
  docker:
    web: Dockerfile
  1. Create a new Heroku application using Docker:
heroku create --stack container --manifest your-app-name
  1. Modify your app to listen on /tmp/nginx.socket instead of $PORT as $PORT is already occupied by nginx. For example, in an express app configure port as follows:
// app.js
const app = require('express')()

let port = process.env.PORT || 3000 // If Wallarm is not configured, listen on $PORT
if(process.env.WALLARM_API_TOKEN) port = '/tmp/nginx.socket' // Wallarm is configured

app.listen(port, (err) => {
	if (err) throw err
	console.log(`> App is listening on ${port}`)
})

app.get('/', (req, res) => {
  res.send('This app is protected by Wallarm')
})
  1. Push your app
git add Dockerfile heroku.yml app.js package.json
git commit -m "Add Heroku docker config"
git push heroku master

Configuration

The Wallarm base Docker image can be configured using environment variables. The following variables are available:

  • WALLARM_API_TOKEN: Your Wallarm API token or node token. If not set, the image skips Wallarm launch and only runs the command specified in CMD (see entrypoint.sh). The value is required.
  • WALLARM_API_HOST: The Wallarm Cloud API hostname. Use us1.api.wallarm.com for the US cloud or api.wallarm.com for the EU cloud (default: us1.api.wallarm.com).
  • WALLARM_LABELS: The Wallarm node label (default: group=heroku). The group setting is required if you use the API token in place of the node token.
  • TT_MEMTX_MEMORY: Memory size allocated for Tarantool in bytes (default: 268435456, i.e., 256 MB).

Set these variables using the heroku config:set command:

heroku config:set WALLARM_API_TOKEN="your-wallarm-api-token" WALLARM_LABELS="group=myfancyapp"

Troubleshooting

If you encounter any issues while using the Wallarm base Docker image, check the Heroku logs for any error messages:

heroku logs --tail

To build this image and debug it locally run:

docker build -t bonakodo/wallarm-heroku:4.10 --target build --platform linux/amd64 .

If you need further assistance, please create an issue in this repository.

License

This dockerfile and configs are licensed under the BSD-3-Clause license. Wallarm node is licensed under its Software License Agreement.

wallarm-heroku's People

Contributors

bonakodo-eric avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

woutgroenendijk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.