From 73fe20a7bac05000b6066ab87cee5d442788f093 Mon Sep 17 00:00:00 2001 From: christiansegercrantz <44305721+christiansegercrantz@users.noreply.github.com> Date: Wed, 29 May 2024 11:38:27 +0000 Subject: [PATCH] Added devcontainer --- .devcontainer/Dockerfile | 20 ++++++++++++++++++ .devcontainer/devcontainer.json | 36 ++++++++++++++++++++++++++++++++ .devcontainer/package_install.sh | 5 +++++ README.md | 7 +++++-- docker-compose.yml | 5 ++--- 5 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/package_install.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..818192a --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,20 @@ +# Use the specified base image +FROM mcr.microsoft.com/devcontainers/universal:2-linux + +# Install Node.js (example uses Node.js 14, adjust as needed) +ARG NODE_VERSION=16 +RUN curl -fsSL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \ + && apt-get install -y nodejs \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* + +# Install yarn +RUN npm install -g yarn + +# Install MongoDB +RUN apt-get update \ + && apt-get install -y gnupg \ + && curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add - \ + && echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list \ + && apt-get update \ + && apt-get install -y mongodb-org \ + && apt-get clean -y && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..1bd0766 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,36 @@ +{ + "name": "Phuxpoangshafte dev container", + // Use a Dockerfile to define the container image + "build": { + "dockerfile": "Dockerfile" + }, + "runArgs": ["--name", "phuxpoangshafte-dev-container"], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "sh .devcontainer/package_install.sh", + "customizations": { + "vscode": { + "extensions": [ + "qufiwefefwoyn.inline-sql-syntax", + "VisualStudioExptTeam.vscodeintellicode", + "Zignd.html-css-class-completion", + "cmstead.js-codeformer", + "christian-kohler.path-intellisense", + "esbenp.prettier-vscode", + "mechatroner.rainbow-csv", + "humao.rest-client", + "ms-vscode.vscode-typescript-next", + "infeng.vscode-react-typescript", + "ms-azuretools.vscode-docker" + ] + } + } + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} \ No newline at end of file diff --git a/.devcontainer/package_install.sh b/.devcontainer/package_install.sh new file mode 100644 index 0000000..d06dd90 --- /dev/null +++ b/.devcontainer/package_install.sh @@ -0,0 +1,5 @@ +cd back +yarn install + +cd ../front +yarn install \ No newline at end of file diff --git a/README.md b/README.md index 9cab875..463da37 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ First, make sure that you have docker and mongodb installed on your computer. Then you can run the following to set up the local environment: ``` -docker-compose up --build +docker compose up --build ``` The backend runs on port 8000 and the frontend on 3000 @@ -15,4 +15,7 @@ However, if you want to run the front & backend separately, you can do it by run ``` make install make run -``` \ No newline at end of file +``` + +### Alternative way using VS code dev containers +You can also dev and run this using [VS code Dev containers](https://code.visualstudio.com/docs/devcontainers/containers). You do this by installing the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension as well as having Docker on your computer (in case you are still running Win10 this might not work). After that you can open the repo in a container using "Dev Containers: Clone a repository in Container Volume..." command from the VS code command palette. Note: No need to clone the repo before that to your computer. This should give you a working development environment. After this you can simply run the same commands above to start the service. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4a9a99d..774e141 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,10 @@ -version: "3" - services: back: restart: always build: context: . args: - REACT_APP_PHUX_YEAR: 2022 + REACT_APP_PHUX_YEAR: 2024 ports: - "8000:8000" container_name: back_phux @@ -22,6 +20,7 @@ services: - SECRET=kossusmakarbasturmetalkopp2021 depends_on: - db + db: container_name: phux-db image: postgres:16.1-alpine3.18