Skip to content

Commit

Permalink
dockerize the corsair app
Browse files Browse the repository at this point in the history
  • Loading branch information
bpmason1 committed Jan 8, 2020
1 parent 38c50c5 commit 2680b16
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM rust:1.40.0-alpine as builder

RUN if [ ! -d /tmp ]; then mkdir /tmp; fi

WORKDIR /tmp

COPY Cargo.toml .
COPY Cargo.lock .
COPY src ./src

RUN cargo build --release

#-------------------------------------------------------------
FROM alpine:3.11.2

RUN apk add --no-cache bash

COPY --from=builder /tmp/target/release/corsair .

COPY scripts ./scripts

# ENV LISTEN_ADDR=127.0.0.1:8000 PROXY_ADDR=127.0.0.1:4000
CMD ["./scripts/run"]

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ CORS-ignoring proxy
The `--permissive` flag indicates that all CORS requests should be accepted for proxying.
The flag is required for now because I have not yet implemented logic to configure CORS rules.

### run with Docker
```
docker build -t corsiar .
docker run -it --net=host -e LISTEN_ADDR=127.0.0.1:8080 -e PROXY_ADDR=127.0.0.1:4000 bpmason1/corsair
```

23 changes: 23 additions & 0 deletions scripts/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /bin/bash

set -e

RED='\033[0;31m'
NC='\033[0m' # No Color

if [ -z $LISTEN_ADDR ]; then
echo "ERROR - unset environment variable LISTEN_ADDR"
exit 1
fi

if [ -z $PROXY_ADDR ]; then
echo "ERROR - unset environment variable PROXY_ADDR"
exit 1
fi

SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR=$(cd $SCRIPTS_DIR/.. && pwd)

# this is convenient for running the application in a docker container
./corsair --listen-ip=${LISTEN_ADDR} --proxy-ip=${PROXY_ADDR} --permissive

0 comments on commit 2680b16

Please sign in to comment.