ADD: Docker-compose dev environment

This commit is contained in:
Nicolas Meienberger 2022-05-17 19:29:12 +02:00
parent 87eb3c7b94
commit 67ca2c5ced
5 changed files with 95 additions and 3 deletions

55
docker-compose.dev.yml Normal file
View file

@ -0,0 +1,55 @@
version: "3.7"
services:
api:
build:
context: ./packages/system-api
dockerfile: Dockerfile.dev
container_name: api
ports:
- 3001:3001
volumes:
## Docker sock
- /var/run/docker.sock:/var/run/docker.sock:ro
- ${PWD}:/tipi
- ${PWD}/packages/system-api:/app
- /app/node_modules
environment:
- INTERNAL_IP=${INTERNAL_IP}
- TIPI_VERSION=${TIPI_VERSION}
- JWT_SECRET=${JWT_SECRET}
- ROOT_FOLDER_HOST=${ROOT_FOLDER_HOST}
networks:
- tipi_main_network
dashboard:
build:
context: ./packages/dashboard
dockerfile: Dockerfile.dev
container_name: dashboard
ports:
- 3000:3000
networks:
- tipi_main_network
environment:
- INTERNAL_IP=${INTERNAL_IP}
volumes:
- ${PWD}/packages/dashboard:/app
- /app/node_modules
labels:
traefik.enable: true
traefik.http.routers.dashboard.rule: PathPrefix("/") # Host(`tipi.local`) &&
traefik.http.routers.dashboard.entrypoints: webinsecure
traefik.http.routers.dashboard.service: dashboard
traefik.http.services.dashboard.loadbalancer.server.port: 3000
networks:
tipi_main_network:
driver: bridge
driver_opts:
com.docker.network.bridge.enable_ip_masquerade: "true"
com.docker.network.bridge.enable_icc: "true"
ipam:
driver: default
config:
- subnet: 10.21.21.0/24

View file

@ -5,7 +5,9 @@
"scripts": {
"prepare": "husky install",
"act:test-install": "act --container-architecture linux/amd64 -j test-install",
"act:docker": "act --container-architecture linux/amd64 --secret-file github.secrets -j docker"
"act:docker": "act --container-architecture linux/amd64 --secret-file github.secrets -j docker",
"start:dev": "docker-compose -f docker-compose.dev.yml --env-file .env.dev up --build",
"start:prod": "docker-compose --env-file .env up --build"
},
"dependencies": {
"eslint": "^8.15.0",

View file

@ -3,7 +3,6 @@ FROM node:latest
WORKDIR /app
COPY ./package.json ./
COPY ./yarn.lock ./
RUN yarn

View file

@ -0,0 +1,36 @@
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /app
# Install docker
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
RUN echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update
RUN apt-get install -y docker-ce docker-ce-cli containerd.io
# Install node
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs
# Install docker-compose
RUN curl -L "https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
RUN chmod +x /usr/local/bin/docker-compose
COPY ./package.json ./
RUN npm install
COPY ./ ./
CMD ["npm", "run", "dev"]

View file

@ -15,7 +15,7 @@
"build": "esbuild --bundle src/server.ts --outdir=dist --allow-overwrite --sourcemap --platform=node --minify --analyze=verbose --external:./node_modules/* --format=esm",
"build:watch": "esbuild --bundle src/server.ts --outdir=dist --allow-overwrite --sourcemap --platform=node --external:./node_modules/* --format=esm --watch",
"start:dev": "NODE_ENV=development nodemon --trace-deprecation --trace-warnings --watch dist dist/server.js",
"dev": "concurrently \"yarn build:watch\" \"yarn start:dev\"",
"dev": "concurrently \"npm run build:watch\" \"npm run start:dev\"",
"start": "NODE_ENV=production node dist/server.js"
},
"author": "",