Skip to content

Commit fa1f9a5

Browse files
author
Matt Bernier
authored
Merge pull request #67 from mithunsasidharan/master
Adding Docker support
2 parents 7a75d24 + f9508e5 commit fa1f9a5

File tree

5 files changed

+131
-1
lines changed

5 files changed

+131
-1
lines changed

docker/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM store/oracle/serverjre:8
2+
3+
ENV OAI_SPEC_URL="https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json"
4+
5+
RUN yum install -y git
6+
7+
WORKDIR /root
8+
9+
# install Prism
10+
ADD https://raw.githubusercontent.com/stoplightio/prism/master/install.sh install.sh
11+
RUN chmod +x ./install.sh && sync && \
12+
./install.sh && \
13+
rm ./install.sh
14+
15+
# set up default sendgrid env
16+
WORKDIR /root/sources
17+
RUN git clone https://github.com/sendgrid/java-http-client.git
18+
19+
WORKDIR /root
20+
RUN ln -s /root/sources/java-http-client/sendgrid
21+
22+
COPY entrypoint.sh entrypoint.sh
23+
RUN chmod +x entrypoint.sh
24+
25+
# Set entrypoint
26+
ENTRYPOINT ["./entrypoint.sh"]
27+
CMD ["--mock"]

docker/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Supported tags and respective `Dockerfile` links
2+
- `v1.0.0`, `latest` [(Dockerfile)](https://github.com/sendgrid/java-http-client/blob/master/docker/Dockerfile)
3+
4+
# Quick reference
5+
Due to Oracle's JDK license, you must build this Docker image using the official Oracle image located in the Docker Store. You will need a Docker store account. Once you have an account, you must accept the Oracle license [here](https://store.docker.com/images/oracle-serverjre-8). On the command line, type `docker login` and provide your credentials. You may then build the image using this command `docker build -t sendgrid/java-http-client -f Dockerfile .`
6+
7+
- **Where to get help:**
8+
[Contact SendGrid Support](https://support.sendgrid.com/hc/en-us)
9+
10+
- **Where to file issues:**
11+
https://github.com/sendgrid/java-http-client/issues
12+
13+
- **Where to get more info:**
14+
[USAGE.md](https://github.com/sendgrid/java-http-client/blob/master/docker/USAGE.md)
15+
16+
- **Maintained by:**
17+
[SendGrid Inc.](https://sendgrid.com)
18+
19+
# Usage examples
20+
- Most recent version: `docker run -it sendgrid/java-http-client`.
21+
- Your own fork:
22+
```sh-session
23+
$ git clone https://github.com/you/cool-java-http-client.git
24+
$ realpath cool-java-http-client
25+
/path/to/cool-java-http-client
26+
$ docker run -it -v /path/to/cool-java-http-client:/mnt/java-http-client sendgrid/java-http-client
27+
```
28+
29+
For more detailed information, see [USAGE.md](https://github.com/sendgrid/java-http-client/blob/master/docker/USAGE.md).
30+
31+
# About
32+
33+
java-http-client is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com).
34+
35+
java-http-client is maintained and funded by SendGrid, Inc. The names and logos for java-http-client are trademarks of SendGrid, Inc.
36+
37+
![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)

docker/USAGE.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
You can use Docker to easily try out or test java-http-client.
2+
3+
<a name="Quickstart"></a>
4+
# Quickstart
5+
6+
1. Install Docker on your machine.
7+
2. If you have not done so, create a Docker Store account [here](https://store.docker.com/signup?next=%2F)
8+
3. Navigate [here](https://store.docker.com/images/oracle-serverjre-8) and click the "Proceed to Checkout" link (don't worry, it's free).
9+
4. On the command line, execute `docker login` and provide your credentials.
10+
5. Build the Docker image using the command `docker build -t sendgrid/java-http-client -f Dockerfile .`
11+
6. Run `docker run -it sendgrid/java-http-client`.
12+
13+
<a name="Info"></a>
14+
# Info
15+
16+
This Docker image contains
17+
- `java-http-client`
18+
- Stoplight's Prism, which lets you try out the API without actually sending email
19+
20+
Run it in interactive mode with `-it`.
21+
22+
You can mount repositories in the `/mnt/java-http-client` and `/mnt/java-http-client` directories to use them instead of the default SendGrid libraries. Read on for more info.
23+
24+
<a name="Testing"></a>
25+
# Testing
26+
Testing is easy! Run the container, `cd sendgrid`, and run `./gradlew test`.
27+
28+
<a name="about"></a>
29+
# About
30+
31+
java-http-client is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com).
32+
33+
java-http-client is maintained and funded by SendGrid, Inc. The names and logos for java-http-client are trademarks of SendGrid, Inc.
34+
35+
![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)

docker/entrypoint.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#! /bin/bash
2+
clear
3+
4+
# check for + link mounted libraries:
5+
if [ -d /mnt/java-http-client ]
6+
then
7+
rm /root/sendgrid
8+
ln -s /mnt/java-http-client/sendgrid
9+
echo "Linked mounted java-http-client's code to /root/sendgrid"
10+
fi
11+
12+
SENDGRID_JAVA_VERSION="1.0.0"
13+
echo "Welcome to java-http-client docker v${SENDGRID_JAVA_VERSION}."
14+
echo
15+
16+
if [ "$1" != "--no-mock" ]
17+
then
18+
echo "Starting Prism in mock mode. Calls made to Prism will not actually send emails."
19+
echo "Disable this by running this container with --no-mock."
20+
prism run --mock --spec $OAI_SPEC_URL 2> /dev/null &
21+
else
22+
echo "Starting Prism in live (--no-mock) mode. Calls made to Prism will send emails."
23+
prism run --spec $OAI_SPEC_URL 2> /dev/null &
24+
fi
25+
echo "To use Prism, make API calls to localhost:4010. For example,"
26+
echo " sg = sendgrid.SendGridAPIClient("
27+
echo " host='http://localhost:4010/',"
28+
echo " api_key=os.environ.get('SENDGRID_API_KEY_CAMPAIGNS'))"
29+
echo "To stop Prism, run \"kill $!\" from the shell."
30+
31+
bash

src/test/java/com/sendgrid/TestRequiredFilesExist.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class TestRequiredFilesExist {
88

99
// ./Docker or docker/Docker
1010
@Test public void checkDockerExists() {
11-
boolean dockerExists = new File("./Docker").exists() ||
11+
boolean dockerExists = new File("./docker/Dockerfile").exists() ||
1212
new File("./docker/Docker").exists();
1313
assertTrue(dockerExists);
1414
}

0 commit comments

Comments
 (0)