Skip to content

Instantly share code, notes, and snippets.

@gnschenker
gnschenker / Dockerfile
Created October 16, 2019 14:06
VS generated Dockerfile for a Web API using .NET Core 3.0
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["WebApplication1/WebApplication1.csproj", "WebApplication1/"]
RUN dotnet restore "WebApplication1/WebApplication1.csproj"
COPY . .
@gnschenker
gnschenker / launch.json
Created October 10, 2019 14:13
Launch configuration for in-container debugging
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Docker Attach (Compose)",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickRemoteProcess}",
"pipeTransport": {
"pipeProgram": "docker-compose",
@gnschenker
gnschenker / docker-compose-debug.yml
Created October 10, 2019 13:59
Docker Compose file used to debug a microservice running inside a container
version: "2.4"
services:
db:
image: postgres:12.0-alpine
volumes:
- pg-data:/var/lib/postgresql/data
- ./db/init:/docker-entrypoint-initdb.d
ports:
- 5432
environment:
@gnschenker
gnschenker / Dockerfile
Created October 10, 2019 13:47
A Dockerfile used during debugging inside a container
FROM mcr.microsoft.com/dotnet/core/sdk:2.2
RUN apt update && \
apt install unzip && \
curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l /vsdbg
WORKDIR /app
COPY ./bin/Debug/netcoreapp2.2/publish /app
CMD dotnet api.dll
@gnschenker
gnschenker / api-spec.js
Last active October 9, 2019 12:04
Added first real test to api-spec.js
const axios = require('axios');
describe('ACME API test suite', () => {
describe('Some smoke test...', () => {
it('should succeed!', () => {
expect(true).toBe(true);
})
})
describe('When calling GET /api/values', () =>{
@gnschenker
gnschenker / api-spec.js
Created October 8, 2019 15:28
Smoke test for our integration tests suite
describe('ACME API test suite', () => {
describe('Some smoke test...', () => {
it('should succeed!', () => {
expect(true).toBe(true);
})
})
})
@gnschenker
gnschenker / docker-compose-it.yml
Created October 8, 2019 14:58
Docker Compose file for continuous integration test runs
version: "2.4"
services:
db:
image: postgres:12.0-alpine
volumes:
- pg-data:/var/lib/postgresql/data
- ./db/init:/docker-entrypoint-initdb.d
ports:
- 5432
environment:
version: "2.4"
services:
db:
image: postgres:12.0-alpine
volumes:
- pg-data:/var/lib/postgresql/data
- ./db/init:/docker-entrypoint-initdb.d
ports:
- 5432
environment:
@gnschenker
gnschenker / Dockerfile
Created October 4, 2019 10:22
Dockerfile for API microservice
FROM mcr.microsoft.com/dotnet/core/sdk:2.2
WORKDIR /app
COPY api.csproj ./
RUN dotnet restore
COPY . .
CMD dotnet run
@gnschenker
gnschenker / init-db.sql
Created October 4, 2019 08:47
Provision the database
CREATE TABLE hobbies(
hobby_id serial PRIMARY KEY,
hobby VARCHAR (50) UNIQUE NOT NULL
);
INSERT INTO hobbies(hobby) VALUES('jogging');
INSERT INTO hobbies(hobby) VALUES('hiking');
INSERT INTO hobbies(hobby) VALUES('swimming');
INSERT INTO hobbies(hobby) VALUES('diving');
INSERT INTO hobbies(hobby) VALUES('cooking');