-
Notifications
You must be signed in to change notification settings - Fork 583
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
Initial dockerfile #557
Merged
Merged
Initial dockerfile #557
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM microsoft/dotnet:1.0-sdk | ||
|
||
# Install Prism | ||
ADD https://raw.githubusercontent.com/stoplightio/prism/master/install.sh install.sh | ||
RUN chmod +x ./install.sh && \ | ||
./install.sh && \ | ||
rm ./install.sh | ||
|
||
# Clone sources | ||
WORKDIR /root/sources | ||
RUN git clone https://github.com/sendgrid/sendgrid-csharp.git | ||
|
||
# Set up symlink | ||
RUN ln -s /root/sources/sendgrid-csharp /root/sendgrid-csharp | ||
WORKDIR /root/sendgrid-csharp | ||
|
||
# Restore packages | ||
RUN dotnet restore | ||
|
||
# Set up prism | ||
ENV OAI_SPEC_URL="https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json" | ||
RUN mkdir prism/bin && ./prism/prism.sh | ||
ENV PATH="${PATH}:$PWD/prism/bin/" | ||
|
||
# Hack to prevent tests from attempting to start (windows) prism | ||
ENV TRAVIS="true" | ||
|
||
# Start prism with the container | ||
COPY entrypoint.sh entrypoint.sh | ||
RUN chmod +x entrypoint.sh | ||
|
||
# Set entrypoint | ||
ENTRYPOINT ["./entrypoint.sh"] | ||
CMD ["--mock"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
You can use Docker to easily try out or test sendgrid-csharp. | ||
|
||
# Quickstart | ||
|
||
1. Install Docker on your machine. | ||
2. Build the latest container with `docker build -t sendgrid/sendgrid-csharp docker` | ||
3. Run `docker run -it sendgrid/sendgrid-csharp`. | ||
|
||
# Info | ||
|
||
This Docker image contains | ||
- `sendgrid-csharp` | ||
- Stoplight's Prism, which lets you try out the API without actually sending email | ||
|
||
Run it in interactive mode with `-it`. | ||
|
||
You can mount a repository in the `/mnt/sendgrid-csharp` directory to use it instead of the default SendGrid library. | ||
|
||
# Testing | ||
Testing is easy! Run the container, then `dotnet test ./tests/SendGrid.Tests/SendGrid.Tests.csproj -c Release -f netcoreapp1.0` | ||
|
||
# Usage examples | ||
|
||
- Most recent version: docker run -it sendgrid/sendgrid-csharp. | ||
- Your own fork: | ||
```sh-session | ||
$ git clone https://github.com/you/cool-sendgrid-csharp.git | ||
$ realpath cool-sendgrid-csharp | ||
/path/to/cool-sendgrid-csharp | ||
$ docker run -it -v /path/to/cool-sendgrid-csharp:/mnt/sendgrid-csharp sendgrid/sendgrid-csharp | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#! /bin/bash | ||
|
||
# check for + link mounted libraries: | ||
if [ -d /mnt/sendgrid-csharp ] | ||
then | ||
rm /root/sendgrid-csharp | ||
ln -s /mnt/sendgrid-csharp /root/sendgrid-csharp | ||
echo "Linked mounted sendgrid-csharp" | ||
fi | ||
|
||
echo "Welcome to sendgrid-csharp docker." | ||
echo | ||
|
||
if [ "$1" != "--no-mock" ] | ||
then | ||
echo "Starting Prism in mock mode. Calls made to Prism will not actually send emails." | ||
echo "Disable this by running this container with --no-mock." | ||
prism run --mock --spec $OAI_SPEC_URL 2> /dev/null & | ||
else | ||
echo "Starting Prism in live (--no-mock) mode. Calls made to Prism will send emails." | ||
prism run --spec $OAI_SPEC_URL 2> /dev/null & | ||
fi | ||
echo "To use Prism, make API calls to localhost:4010. For example," | ||
echo " var sg = new SendGridClient(Environment.GetEnvironmentVariable('SENDGRID_API_KEY_CAMPAIGNS'), | ||
'http://localhost:4010')" | ||
echo "To stop Prism, run \"kill $!\" from the shell." | ||
|
||
cd /root/sendgrid-csharp | ||
exec $SHELL |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's what I tried:
The error I got:
I also tried:
and got a similar error:
Do you know what I did incorrectly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FireEater64 Can you please give this a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mbernier - I wrote these instructions under the assumption that someone @sendgrid would build and push this container to the docker hub. Since I'm not a member of the sendgrid org, I can't do it myself, at least not under that name.
I can rework the instructions if you'd like - but to build the container yourself, just check out the branch and run
docker build -t sendgrid/sendgrid-csharp .
Then the instructions you mentioned above should work 😄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, gotcha! Yes, we will eventually get this into docker hub. Until then, we want to make sure that people can run it from the library.
When we add it to docker hub we will update the docs accordingly!!
Can you please make the suggested change? Then we will get this merged.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course - should be done 👍