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 dockerfile to start server in a docker container #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FuriKuri
Copy link

@FuriKuri FuriKuri commented Oct 3, 2018

I've added a simple dockerfile so it is easier to start your own server.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 67f033b on FuriKuri:master into 2ee3147 on Rob--W:master.

@Rob--W
Copy link
Owner

Rob--W commented Oct 3, 2018

Thanks for this PR. I'm not merging it because it does not offer critical functionality, but I'll keep the PR open so that others who are looking for an example of using CORS Anywhere in a Docker container.

Repository owner deleted a comment from coveralls Oct 3, 2018
Repository owner deleted a comment from coveralls Oct 3, 2018
Repository owner deleted a comment from coveralls Oct 3, 2018
@wafisher
Copy link

wafisher commented Dec 2, 2018

I like this PR! cors-anywhere exists to be deployed, why not make it easier using a very standard tool (Docker)? I would imagine lots of people coming here end up using Docker to deploy. Just my two cents.

@RomanHotsiy
Copy link

Merging this PR and setting up automatic builds would help a lot!
Right now lots of people are creating their own images with cors-anywhere inside and push it to docker hub. I researched a few of them and looks like I have to build one more :( as they all are user-specific (e.g. https://github.com/psimonov/cors-anywhere/blob/master/app.js#L9)

Having an official cors-anywhere image, I would set up and run an instance e.g. in AWS ECS in a few clicks of the mouse.

@Rob--W please, consider merging this!

Thanks for your work!

@revolunet
Copy link

Hi, this would be an useful addition because it makes cors-anywhere executable from any non-node server with a single docker run cors-anywhere :)

@jiri-jirus
Copy link

hello, dockerfile offers critical functionality for those who need to actually deploy it. docker is today's standard way to deploy stuff.

@madhav411
Copy link

I've added a simple dockerfile so it is easier to start your own server.

I run the cors-anywhere container using your dockerfile,When i run the docker image this is the output i am getting in the browser

This API enables cross-origin requests to anywhere.

Usage:

/               Shows help
/iscorsneeded   This is the only resource on this host which is served without CORS headers.
/<url>          Create a request to <url>, and includes CORS headers in the response.

If the protocol is omitted, it defaults to http (https if port 443 is specified).

Cookies are disabled and stripped from requests.

Redirects are automatically followed. For debugging purposes, each followed redirect results
in the addition of a X-CORS-Redirect-n header, where n starts at 1. These headers are not
accessible by the XMLHttpRequest API.
After 5 redirects, redirects are not followed any more. The redirect response is sent back
to the browser, which can choose to follow the redirect (handled automatically by the browser).

The requested URL is available in the X-Request-URL response header.
The final URL, after following all redirects, is available in the X-Final-URL response header.


To prevent the use of the proxy for casual browsing, the API requires either the Origin
or the X-Requested-With header to be set. To avoid unnecessary preflight (OPTIONS) requests,
it's recommended to not manually set these headers in your code.


Demo          :   https://robwu.nl/cors-anywhere.html
Source code   :   https://github.com/Rob--W/cors-anywhere/
Documentation :   https://github.com/Rob--W/cors-anywhere/#documentation

Is this means,cors-anywhere running successfully in my local ?, If yes please let me know how to test.

Thanks in advance :)

@Rob--W
Copy link
Owner

Rob--W commented Feb 20, 2021

@FuriKuri Yes seeing that page means that CORS Anywhere is running. To test it, follow the instructions as shown in that text that you're seeing.

@emerald1000
Copy link

emerald1000 commented Feb 25, 2021

@FuriKuri Yes seeing that page means that CORS Anywhere is running. To test it, follow the instructions as shown in that text that you're seeing.

@Rob--W

Hi, could you help me on this? I deployed cors-anywhere to Azure App Service. When I call this https://corsproxy-execute.azurewebsites.net/https://www.google.com.sg/, for example, instead of going to google, it shows the default texts as below. Am I doing something wrong? Kindly advise.

This API enables cross-origin requests to anywhere.

Usage:

/ Shows help
/iscorsneeded This is the only resource on this host which is served without CORS headers.
/ Create a request to , and includes CORS headers in the response.

If the protocol is omitted, it defaults to http (https if port 443 is specified).

Cookies are disabled and stripped from requests.

Redirects are automatically followed. For debugging purposes, each followed redirect results
in the addition of a X-CORS-Redirect-n header, where n starts at 1. These headers are not
accessible by the XMLHttpRequest API.
After 5 redirects, redirects are not followed any more. The redirect response is sent back
to the browser, which can choose to follow the redirect (handled automatically by the browser).

The requested URL is available in the X-Request-URL response header.
The final URL, after following all redirects, is available in the X-Final-URL response header.

To prevent the use of the proxy for casual browsing, the API requires either the Origin
or the X-Requested-With header to be set. To avoid unnecessary preflight (OPTIONS) requests,
it's recommended to not manually set these headers in your code.

Demo : https://robwu.nl/cors-anywhere.html
Source code : https://github.com/Rob--W/cors-anywhere/
Documentation : https://github.com/Rob--W/cors-anywhere/#documentation

@bulk88
Copy link
Contributor

bulk88 commented Oct 15, 2023

I switched long ago from heroku, to fly.io, fly.io DOES allow building from heroku build files, but the Fly Docker image, with Heroku specific stuff, has 400 MBs more userland junk (more heroku specific NPM default node packages, more handy .so files CORS-A and node will never use, and other framework runtimes, IDK, python, php, and friends), in the image (700 MB vs 250 MB), than Node on Docker on Fly. Also the Fly+Heroku public API emulation layer, where fly adds shell scripts and binaries that emulate heroku env vars, in your VM, before launching node, those heroku emulation/heartbeat shell scripts and binaries are added ABOVE your CORS-A node_packages docker layer, causing docker image bloat. I don't remember if Fly+Heroku emulation VM has 1-2 extra no-CPU used processes hanging around, but be a good citizen, and dont use Heroku emulator on Fly. Build times on a github actions push are much faster, if you strip "Heroku Ubuntu" and switch to "node-slim Ubuntu"

.github\workflows\fly.yml

name: Fly Deploy
on:
  push:
    branches:
    - '*'

env:
  FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
  NODE_ENV: production

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: superfly/flyctl-actions/setup-flyctl@master
      - run: flyctl version
      - run: flyctl deploy --remote-only

Dockerfile

# syntax = docker/dockerfile:1

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

LABEL fly_launch_runtime="NodeJS"

# NodeJS 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 install

# Copy application code
COPY --link . .



# 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
CMD [ "npm", "run", "start" ]

.dockerignore

.dockerignore
.eslintignore
.eslintrc
.git
.github
.gitignore
.travis.yml
Dockerfile
README.md
demo.html??????????????????????MAYBE_U_KEEP_THIS_I_DELETE_IT
fly.toml
privkey.pem??????SPECIFIC_MY_FORK
pubcert.pem??????SPECIFIC_MY_FORK
test

fly.toml

# fly.toml file generated for APPNAMEFIXME on 2023-02-08T23:24:03-05:00

app = "APPNAMEFIXME"
primary_region = "ewrREGIONFIXME"
kill_signal = "SIGINT"
kill_timeout = 5

[build]
  [build.args]
    NODE_ENV = "production"

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true
  cmd = []
  entrypoint = []
  exec = []

[processes]
  app = "node server.js"

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  min_machines_running = 1
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [services.ports.http_options.response.headers]
    fly-request-id = false
    server = false
    via = false

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants