diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a141076 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,25 @@ +image: docker:dind + +services: + - name: docker:dind + entrypoint: ["env", "-u", "DOCKER_HOST"] + command: ["dockerd-entrypoint.sh"] +variables: + DOCKER_HOST: tcp://docker:2375/ + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "" + +before_script: + - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY + + +build: + stage: build + script: + - docker build . -t backend:$CI_COMMIT_SHORT_SHA + - docker tag backend:$CI_COMMIT_SHORT_SHA $CI_REGISTRY/taskboard/backend:$CI_COMMIT_SHORT_SHA + - docker push $CI_REGISTRY/taskboard/backend:$CI_COMMIT_SHORT_SHA + - docker tag backend:$CI_COMMIT_SHORT_SHA $CI_REGISTRY/taskboard/backend:latest + - docker push $CI_REGISTRY/taskboard/backend:latest + tags: + - backend \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 030b496..0b74f8d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,5 +17,6 @@ ENV DATABASE_PORT 5432 ENV DATABASE_NAME null ENV DATABASE_USER null ENV DATABASE_PASSWORD null +EXPOSE 80 ENTRYPOINT ["dotnet", "ScrumTaskboard.dll"] \ No newline at end of file diff --git a/README.md b/README.md index d61f4ff..a860647 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,14 @@ > Prerequisite: Docker and Docker Compose have to be installed on your system
> The Docker installation instructions for most operation systems can be found here: [https://docs.docker.com/get-docker/](https://docs.docker.com/get-docker/)
> The Docker Compose installation instructions for most operation systems can be found here: [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/) +> To use the prebuild images log into the private registry: docker login -u testuser -p LpH2v1mShPpC8Xeimkd2AISA03zaC+vq scrumdev.azurecr.io ### Quick Deployment with Docker Compose 1. Clone the git repo 2. Open the cloned repo's folder in a shell of your choice (as long as it supports Docker) -3. Tell Docker Compose to build - if it hasn't already been built - and run the app with `docker-compose up` +3. Tell Docker Compose to run the app alongside a database with `docker-compose up` Other useful commands: -* Just build: `docker-compose build` -* Build before running: `docker-compose up --build` * Run attached (in the background): `docker-compose up -d` * Stop: `docker-compose down` * Restart: `docker-compose restart` @@ -20,9 +19,9 @@ Other useful commands: ### Build the Container yourself (and run it) 1. Clone the git repo 2. Open the cloned repo's folder in a shell of your choice (as long as it supports Docker) -3. Tell Docker to build the app under the name "taskboard" with `docker build -t taskboard_backend .` -4. Tell Docker to run the app on port 8080 with `docker run -p 8080:80 taskboard_backend` +3. Tell Docker to build the app under the name "taskboard" with `docker build -t taskboard/backend .` +4. Tell Docker to run the app on port 5001 with `docker run -p 5001:80 taskboard/backend` Other useful commands: -* Run detached: `docker run -d -p 8080:80 taskboard_backend` -* Run under specified name: `docker run -p 8080:80 --name backend taskboard_backend` \ No newline at end of file +* Run detached: `docker run -d -p 5001:80 taskboard/backend` +* Run under specified name: `docker run -p 5001:80 --name backend taskboard/backend` \ No newline at end of file diff --git a/ScrumTaskboard/Startup.cs b/ScrumTaskboard/Startup.cs index 010cc4a..3b8f09d 100644 --- a/ScrumTaskboard/Startup.cs +++ b/ScrumTaskboard/Startup.cs @@ -75,7 +75,11 @@ namespace ScrumTaskboard { endpoints.MapControllers(); }); - app.UseOpenApi(); + app.UseOpenApi(a => { + a.PostProcess = (document, _) => { + document.Schemes = new[] { NSwag.OpenApiSchema.Https, NSwag.OpenApiSchema.Http }; + }; + }); app.UseSwaggerUi3(); } diff --git a/docker-compose.yml b/docker-compose.yml index 2e9f9e3..1872676 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,8 +13,7 @@ services: networks: - default app: - build: - context: . + image: scrumdev.azurecr.io/taskboard/backend:latest restart: unless-stopped depends_on: - db