diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..f26b203 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +{ + "name": "Go", + "dockerComposeFile": "../compose.yml", + "service": "app", + "workspaceFolder": "/app", + "customizations": { + "vscode": { + "settings": {}, + "extensions": [ + "k--kato.intellij-idea-keybindings", + "golang.go", + "ms-azuretools.vscode-docker", + "ms-vscode.makefile-tools" + ] + } + }, + "portsAttributes": { + "8080": { + "label": "API Port", + "onAutoForward": "notify" + } + }, + "overrideCommand": false +} \ No newline at end of file diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 85bb0c5..0000000 --- a/.dockerignore +++ /dev/null @@ -1,12 +0,0 @@ -.editorconfig -.git -AUTHORS.md -CONTRIBUTING.md -LICENSE -Makefile -NOTICE -README.md -vendor/ -arm/ -powerpc/ -mips/ \ No newline at end of file diff --git a/Dockerfile.dev b/Dockerfile.dev index e756c79..2efec49 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -4,10 +4,16 @@ FROM golang:1.20 as build WORKDIR /app COPY go.mod go.sum ./ RUN go mod download +# Dependency used to build Swagger config RUN go install github.com/swaggo/swag/cmd/swag@latest +# Dependencies used for static config +RUN go install golang.org/x/tools/gopls@latest +RUN go install github.com/go-delve/delve/cmd/dlv@latest +RUN go install honnef.co/go/tools/cmd/staticcheck@latest +RUN go install golang.org/x/tools/cmd/godoc@latest + COPY . . +# Refresh Swagger config RUN swag init -d ./internal/api,./ -g router.go EXPOSE 8080 - -CMD ["go", "run", "."] diff --git a/compose.yml b/compose.yml index 8ceffdf..c226264 100644 --- a/compose.yml +++ b/compose.yml @@ -6,8 +6,12 @@ services: build: context: . dockerfile: Dockerfile.dev + command: sleep infinity + volumes: + - .:/app ports: - "8080:8080" + - "6060:6060" env_file: - .env.dev @@ -17,15 +21,4 @@ services: environment: MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_PASSWORD: my_password - MONGO_INITDB_DATABASE: chabo-api - - mongo-express: - container_name: mongo-express - image: mongo-express - restart: always - ports: - - 8081:8081 - environment: - ME_CONFIG_MONGODB_ADMINUSERNAME: root - ME_CONFIG_MONGODB_ADMINPASSWORD: my_password - ME_CONFIG_MONGODB_URL: mongodb://root:my_password@mongo:27017/ \ No newline at end of file + MONGO_INITDB_DATABASE: chabo-api \ No newline at end of file