From 86a3399366536cce46b5001fb3461622aaa3659b Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Tue, 4 May 2021 00:14:39 +0300 Subject: Adds Docker File Signed-off-by: Hassan Abouelela --- .dockerignore | 11 +++++++++++ Dockerfile | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b08266c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +# Ignore Everything +* + +# Include required files +!public/ +!src/ +!.swcrc +!package.json +!tsconfig.json +!webpack.config.js +!yarn.lock diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8b85571 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM node:14-slim +WORKDIR /app + +# Copy in lock files +COPY package.json . +COPY yarn.lock . + +# Install dependencies +RUN yarn install + +# Copy program in +COPY . . + +# Serve the frontend +ENTRYPOINT ["yarn", "run"] +CMD ["start", "--host", "0.0.0.0"] -- cgit v1.2.3 From a3c5b9771fc5e0407e181cca2222eab1187d2d62 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Tue, 4 May 2021 00:15:56 +0300 Subject: Adds Docker Compose Includes backend and all dependencies, loads project files as volumes, and forwards port 3000. Signed-off-by: Hassan Abouelela --- docker-compose.yaml | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..d66ff9b --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,52 @@ +version: "3.6" + +services: + mongo: + image: mongo:latest + ports: + - 27017:27017 + environment: + MONGO_INITDB_ROOT_USERNAME: forms-backend + MONGO_INITDB_ROOT_PASSWORD: forms-backend + MONGO_INITDB_DATABASE: pydis_forms + + snekbox: + image: ghcr.io/python-discord/snekbox:latest + ipc: none + ports: + - "127.0.0.1:8060:8060" + privileged: true + + backend: + image: ghcr.io/python-discord/forms-backend + ports: + - 8000:8000 + environment: + - DATABASE_URL=mongodb://forms-backend:forms-backend@mongo:27017 + - SNEKBOX_URL=http://snekbox:8060/eval + - OAUTH2_CLIENT_ID + - OAUTH2_CLIENT_SECRET + - ALLOWED_URL + - DEBUG=true + - PRODUCTION=false + env_file: + - .env + + frontend: + build: + context: . + dockerfile: Dockerfile + depends_on: + - backend + volumes: + - ./public:/app/public:ro + - ./src:/app/src:ro + - ./.swcrc:/app/.swcrc:ro + - ./tsconfig.json:/app/tsconfig.json:ro + - ./webpack.config.js:/app/webpack.config.js:ro + ports: + - 3000:3000 + environment: + - BACKEND_URL=http://localhost:8000/ + env_file: + - .env -- cgit v1.2.3 From a67b488fd3c24507d5892fd601d571f3d8b0e866 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Sun, 30 Jan 2022 10:03:48 +0400 Subject: Bump Node in Dockerfile Bumps the node version in the dockerfile, and cleans up the docker compose. --- Dockerfile | 2 +- docker-compose.yaml | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8b85571..5468d09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14-slim +FROM node:16-slim WORKDIR /app # Copy in lock files diff --git a/docker-compose.yaml b/docker-compose.yaml index d66ff9b..1e4c405 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,7 +4,7 @@ services: mongo: image: mongo:latest ports: - - 27017:27017 + - "27017:27017" environment: MONGO_INITDB_ROOT_USERNAME: forms-backend MONGO_INITDB_ROOT_PASSWORD: forms-backend @@ -19,8 +19,11 @@ services: backend: image: ghcr.io/python-discord/forms-backend + depends_on: + - mongo + - snekbox ports: - - 8000:8000 + - "8000:8000" environment: - DATABASE_URL=mongodb://forms-backend:forms-backend@mongo:27017 - SNEKBOX_URL=http://snekbox:8060/eval @@ -39,13 +42,10 @@ services: depends_on: - backend volumes: - - ./public:/app/public:ro - - ./src:/app/src:ro - - ./.swcrc:/app/.swcrc:ro - - ./tsconfig.json:/app/tsconfig.json:ro - - ./webpack.config.js:/app/webpack.config.js:ro + - .:/app:ro + - /app/node_modules # Ensure dependencies do not collide with a user's local install ports: - - 3000:3000 + - "3000:3000" environment: - BACKEND_URL=http://localhost:8000/ env_file: -- cgit v1.2.3