diff --git a/.github/workflows/auth_test.yml b/.github/workflows/auth_test.yml new file mode 100644 index 0000000..815c2af --- /dev/null +++ b/.github/workflows/auth_test.yml @@ -0,0 +1,36 @@ +name: Auth Test + +on: + push: + branches: + - feature/scaling + + +jobs: + authorizer-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.1.0 + - name: Setup Dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.100' + - name: Install Packages + run: | + dotnet add package StackExchange.Redis --version 2.1.39 --source https://www.myget.org/F/stackoverflow/api/v3/index.json + - name: Build + run: | + dotnet build --configuration Release + - name: Push Tag to Docker Hub + uses: opspresso/action-docker@master + with: + args: --docker + env: + USERNAME: ${{ secrets.DOCKER_USERNAME }} + PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + BUILD_PATH: "authorizer" + DOCKERFILE: "authorizer/Dockerfile" + IMAGE_NAME: "josephbmanley/defend-together-authorizer" + TAG_NAME: "stage" + LATEST: "false" \ No newline at end of file diff --git a/authorizer/Dockerfile b/authorizer/Dockerfile index f240eea..4e17d51 100644 --- a/authorizer/Dockerfile +++ b/authorizer/Dockerfile @@ -1,6 +1,6 @@ FROM mcr.microsoft.com/dotnet/core/runtime:3.1 -COPY bin/Release/netcoreapp3.1/publish/ App/ +COPY bin/Release/netcoreapp3.1/ App/ WORKDIR /App ENTRYPOINT ["dotnet", "authorizer.dll"] diff --git a/authorizer/Program.cs b/authorizer/Program.cs index 62f7484..a0d9c52 100644 --- a/authorizer/Program.cs +++ b/authorizer/Program.cs @@ -1,13 +1,24 @@ using System; +using System.Threading; namespace authorizer { class Program { static AuthServer server; + static Redis redis; static void Main(string[] args) { - server = new AuthServer(); + redis = new Redis(Environment.GetEnvironmentVariable("REDIS_HOSTNAME")); + + redis.SetTest(); + + Thread.Sleep(100); + + redis.GetTest(); + + + /* server = new AuthServer(); server.Start(); @@ -17,7 +28,7 @@ namespace authorizer input = Console.ReadLine(); } while(input != "stop"); - server.Stop(); + server.Stop(); */ } } } diff --git a/authorizer/Redis.cs b/authorizer/Redis.cs new file mode 100644 index 0000000..d358c85 --- /dev/null +++ b/authorizer/Redis.cs @@ -0,0 +1,44 @@ +using System; +using StackExchange.Redis; + +class Redis +{ + private ConnectionMultiplexer muxer; + private IDatabase conn; + private string hostname; + private int port; + public Redis(string host = "127.0.0.1", int p = 6379) + { + if(host == "") + { + throw new Exception("Must provide a redis hostname!"); + } + + //Set private variables + hostname = host; + port = p; + + //Connect to redis cluster + Console.WriteLine("Attempting to connect to: " + host + ":" + p.ToString()); + muxer = ConnectionMultiplexer.Connect(hostname + ":" + port.ToString()); + conn = muxer.GetDatabase(); + Console.WriteLine("Connected to redis server!"); + } + + public void SetTest() + { + string test_val = "Potato"; + conn.StringSet("test_val", test_val); + Console.WriteLine("Set value to: " + test_val); + } + + public void GetTest() + { + Console.WriteLine("Value is: " + conn.StringGet("test_val")); + } + + ~Redis() + { + muxer.Close(); + } +} \ No newline at end of file diff --git a/authorizer/authorizer.csproj b/authorizer/authorizer.csproj index d453e9a..a814ae8 100644 --- a/authorizer/authorizer.csproj +++ b/authorizer/authorizer.csproj @@ -5,4 +5,8 @@ netcoreapp3.1 + + + +