Skip to content

Commit 6bfb67a

Browse files
committed
created docker container
1 parent 1d76c5b commit 6bfb67a

18 files changed

+136
-16
lines changed

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
2+
WORKDIR /app
3+
EXPOSE 80
4+
COPY ["crowdlaunch-backend.csproj", "./"]
5+
RUN dotnet restore "crowdlaunch-backend.csproj"
6+
COPY . .
7+
WORKDIR "/app/."
8+
RUN dotnet build "crowdlaunch-backend.csproj" -c Release -o /app/build
9+
FROM build AS publish
10+
RUN dotnet publish "crowdlaunch-backend.csproj" -c Release -o /app/publish
11+
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS final
12+
WORKDIR /app
13+
COPY --from=publish /app/publish .
14+
ENTRYPOINT ["dotnet", "crowdlaunch-backend.dll"]

Helpers/DatabaseConfig.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ public class DatabaseConfig
77
public DatabaseConfig()
88
{
99
// Retrieve the database password from the environment variables.
10-
string dbPassword = Environment.GetEnvironmentVariable("JiTIjugHfVMJzsEo") ?? throw new Exception("DB_PASSWORD environment variable not found.");
10+
string dbPassword = Environment.GetEnvironmentVariable("DB_PASSWORD") ?? throw new Exception("DB_PASSWORD environment variable not found.");
1111

1212
// Use the retrieved password to build the connection string or perform other configurations.
1313
// For example:
14-
ConnectionString = $"mongodb+srv://folathecoder:JiTIjugHfVMJzsEo@crowdlaunchcluster.veylgng.mongodb.net/?retryWrites=true&w=majority";
14+
ConnectionString = $"mongodb+srv://folathecoder:{dbPassword}@crowdlaunchcluster.veylgng.mongodb.net/?retryWrites=true&w=majority";
1515
}
16-
}
16+
}

Startup.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public void ConfigureServices(IServiceCollection services)
6363
}
6464
);
6565
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
66-
.AddJwtBearer(options => {
66+
.AddJwtBearer(options =>
67+
{
6768
options.TokenValidationParameters = new TokenValidationParameters
6869
{
6970
ValidateIssuer = true,
@@ -93,14 +94,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
9394
{
9495
// Other middleware and configurations...
9596
// Configure the HTTP request pipeline.
96-
if (env.IsDevelopment())
97-
{
98-
app.UseSwagger();
99-
app.UseSwaggerUI();
100-
}
101-
102-
10397

98+
app.UseSwagger();
99+
app.UseSwaggerUI();
104100
app.UseHttpsRedirection();
105101

106102
// using Microsoft.AspNetCore.HttpOverrides;
0 Bytes
Binary file not shown.
-512 Bytes
Binary file not shown.
-20 Bytes
Binary file not shown.

exceptions.log

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,92 @@ Configure your application startup by adding app.UseAuthorization() in the appli
216216
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
217217
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
218218
at ExceptionLoggingMiddleware.InvokeAsync(HttpContext context) in /Users/user/Documents/projects/masters-project/crowdlaunch-backend/MiddleWare/ErrorLoggingMiddleware.cs:line 21
219+
8/9/2023 12:13:18 PM - System.TimeoutException: A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = ReadPreferenceServerSelector{ ReadPreference = { Mode : Primary } }, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/ac-cxqeljl-shard-00-00.veylgng.mongodb.net:27017" }", EndPoint: "Unspecified/ac-cxqeljl-shard-00-00.veylgng.mongodb.net:27017", ReasonChanged: "Heartbeat", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
220+
---> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server.
221+
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
222+
at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytes(Stream stream, Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
223+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(CancellationToken cancellationToken)
224+
--- End of inner exception stack trace ---
225+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(CancellationToken cancellationToken)
226+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken)
227+
--- End of stack trace from previous location ---
228+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken)
229+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessage(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
230+
at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1.Execute(IConnection connection, CancellationToken cancellationToken)
231+
at MongoDB.Driver.Core.Connections.HelloHelper.GetResult(IConnection connection, CommandWireProtocol`1 helloProtocol, CancellationToken cancellationToken)
232+
at MongoDB.Driver.Core.Connections.ConnectionInitializer.SendHello(IConnection connection, CancellationToken cancellationToken)
233+
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)
234+
--- End of inner exception stack trace ---
235+
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)
236+
at MongoDB.Driver.Core.Connections.BinaryConnection.Open(CancellationToken cancellationToken)
237+
at MongoDB.Driver.Core.Servers.ServerMonitor.InitializeConnection(CancellationToken cancellationToken)
238+
at MongoDB.Driver.Core.Servers.ServerMonitor.Heartbeat(CancellationToken cancellationToken)", LastHeartbeatTimestamp: "2023-08-09T11:13:16.1980510Z", LastUpdateTimestamp: "2023-08-09T11:13:16.1980520Z" }, { ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/ac-cxqeljl-shard-00-01.veylgng.mongodb.net:27017" }", EndPoint: "Unspecified/ac-cxqeljl-shard-00-01.veylgng.mongodb.net:27017", ReasonChanged: "Heartbeat", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
239+
---> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server.
240+
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
241+
at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytes(Stream stream, Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
242+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(CancellationToken cancellationToken)
243+
--- End of inner exception stack trace ---
244+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(CancellationToken cancellationToken)
245+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken)
246+
--- End of stack trace from previous location ---
247+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken)
248+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessage(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
249+
at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1.Execute(IConnection connection, CancellationToken cancellationToken)
250+
at MongoDB.Driver.Core.Connections.HelloHelper.GetResult(IConnection connection, CommandWireProtocol`1 helloProtocol, CancellationToken cancellationToken)
251+
at MongoDB.Driver.Core.Connections.ConnectionInitializer.SendHello(IConnection connection, CancellationToken cancellationToken)
252+
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)
253+
--- End of inner exception stack trace ---
254+
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)
255+
at MongoDB.Driver.Core.Connections.BinaryConnection.Open(CancellationToken cancellationToken)
256+
at MongoDB.Driver.Core.Servers.ServerMonitor.InitializeConnection(CancellationToken cancellationToken)
257+
at MongoDB.Driver.Core.Servers.ServerMonitor.Heartbeat(CancellationToken cancellationToken)", LastHeartbeatTimestamp: "2023-08-09T11:13:17.8001940Z", LastUpdateTimestamp: "2023-08-09T11:13:17.8001940Z" }, { ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/ac-cxqeljl-shard-00-02.veylgng.mongodb.net:27017" }", EndPoint: "Unspecified/ac-cxqeljl-shard-00-02.veylgng.mongodb.net:27017", ReasonChanged: "Heartbeat", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
258+
---> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server.
259+
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
260+
at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytes(Stream stream, Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
261+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(CancellationToken cancellationToken)
262+
--- End of inner exception stack trace ---
263+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(CancellationToken cancellationToken)
264+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken)
265+
--- End of stack trace from previous location ---
266+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken)
267+
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessage(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
268+
at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1.Execute(IConnection connection, CancellationToken cancellationToken)
269+
at MongoDB.Driver.Core.Connections.HelloHelper.GetResult(IConnection connection, CommandWireProtocol`1 helloProtocol, CancellationToken cancellationToken)
270+
at MongoDB.Driver.Core.Connections.ConnectionInitializer.SendHello(IConnection connection, CancellationToken cancellationToken)
271+
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)
272+
--- End of inner exception stack trace ---
273+
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)
274+
at MongoDB.Driver.Core.Connections.BinaryConnection.Open(CancellationToken cancellationToken)
275+
at MongoDB.Driver.Core.Servers.ServerMonitor.InitializeConnection(CancellationToken cancellationToken)
276+
at MongoDB.Driver.Core.Servers.ServerMonitor.Heartbeat(CancellationToken cancellationToken)", LastHeartbeatTimestamp: "2023-08-09T11:13:17.0047850Z", LastUpdateTimestamp: "2023-08-09T11:13:17.0047850Z" }] }.
277+
at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
278+
at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)
279+
at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedAsync(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken)
280+
at MongoDB.Driver.Core.Clusters.Cluster.SelectServerAsync(IServerSelector selector, CancellationToken cancellationToken)
281+
at MongoDB.Driver.Core.Clusters.IClusterExtensions.SelectServerAndPinIfNeededAsync(ICluster cluster, ICoreSessionHandle session, IServerSelector selector, CancellationToken cancellationToken)
282+
at MongoDB.Driver.Core.Bindings.ReadPreferenceBinding.GetReadChannelSourceAsync(CancellationToken cancellationToken)
283+
at MongoDB.Driver.Core.Operations.RetryableReadContext.InitializeAsync(CancellationToken cancellationToken)
284+
at MongoDB.Driver.Core.Operations.RetryableReadContext.CreateAsync(IReadBinding binding, Boolean retryRequested, CancellationToken cancellationToken)
285+
at MongoDB.Driver.Core.Operations.FindOperation`1.ExecuteAsync(IReadBinding binding, CancellationToken cancellationToken)
286+
at MongoDB.Driver.OperationExecutor.ExecuteReadOperationAsync[TResult](IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken)
287+
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperationAsync[TResult](IClientSessionHandle session, IReadOperation`1 operation, ReadPreference readPreference, CancellationToken cancellationToken)
288+
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)
289+
at MongoDB.Driver.IAsyncCursorSourceExtensions.ToListAsync[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
290+
at MARKETPLACEAPI.Services.CategoryService.GetAsync() in /Users/user/Documents/projects/masters-project/crowdlaunch-backend/Services/CategoryService.cs:line 30
291+
at MARKETPLACEAPI.Controllers.CategoryController.Get() in /Users/user/Documents/projects/masters-project/crowdlaunch-backend/Controllers/CategoryController.cs:line 22
292+
at lambda_method6(Closure, Object)
293+
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
294+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
295+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
296+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
297+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
298+
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
299+
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
300+
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
301+
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
302+
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
303+
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
304+
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
305+
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
306+
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
307+
at ExceptionLoggingMiddleware.InvokeAsync(HttpContext context) in /Users/user/Documents/projects/masters-project/crowdlaunch-backend/MiddleWare/ErrorLoggingMiddleware.cs:line 21

fly.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# fly.toml app configuration file generated for crowdlaunch-backend on 2023-08-09T11:58:57+01:00
2+
#
3+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+
#
5+
6+
app = "crowdlaunch-backend"
7+
primary_region = "lhr"
8+
9+
[build]
10+
11+
[env]
12+
DB_PASSWORD = "JiTIjugHfVMJzsEo"
13+
JWT_KEY = "Thisisaverylongkey2432fgnfnd5ytrjgrg544gns"
14+
15+
[http_service]
16+
internal_port = 80
17+
force_https = true
18+
auto_stop_machines = true
19+
auto_start_machines = true
20+
min_machines_running = 0
21+
processes = ["app"]

obj/Debug/net7.0/apphost

0 Bytes
Binary file not shown.
1.03 KB
Binary file not shown.

0 commit comments

Comments
 (0)