generated from xgeekshq/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature]: Run project on Docker in Dev mode (#151)
- Create different Dockerfiles - Create custom `docker-compose` file to dev environment - Update pipelines
- Loading branch information
Showing
11 changed files
with
10,907 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
name: Deploy backend | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: azure/docker-login@v1 | ||
with: | ||
login-server: divideandconquer.azurecr.io | ||
username: ${{ secrets.REGISTRY_USERNAME }} | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
- uses: azure/docker-login@v1 | ||
with: | ||
login-server: divideandconquer.azurecr.io | ||
username: ${{ secrets.REGISTRY_USERNAME }} | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
- run: | | ||
docker build . -f ./backend/Dockerfile -t divideandconquer.azurecr.io/backend:latest | ||
docker push divideandconquer.azurecr.io/backend:latest | ||
- run: | | ||
docker build . -f ./backend/docker/prod/Dockerfile -t divideandconquer.azurecr.io/backend:latest | ||
docker push divideandconquer.azurecr.io/backend:latest | ||
- uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: 'divideandconquer-be' | ||
publish-profile: ${{ secrets.AZURE_BACKEND_PUBLISH_PROFILE }} | ||
images: 'divideandconquer.azurecr.io/backend:latest' | ||
- uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: 'divideandconquer-be' | ||
publish-profile: ${{ secrets.AZURE_BACKEND_PUBLISH_PROFILE }} | ||
images: 'divideandconquer.azurecr.io/backend:latest' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Dev Environment | ||
FROM node:16-alpine AS development | ||
|
||
# Container Dir | ||
WORKDIR /app/backend | ||
|
||
# Copy package.json (to install all packages) | ||
COPY package.json ./ | ||
|
||
# Install the packages (on the package.json) | ||
RUN yarn | ||
|
||
# Copy all files | ||
COPY ./ . | ||
|
||
# Run the build command | ||
RUN npm run build |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
version: "3.9" | ||
|
||
services: | ||
backend: | ||
build: | ||
context: backend # starts on backend folder instead on root | ||
target: development # choose development part from Dockerfile | ||
dockerfile: docker/dev/Dockerfile | ||
|
||
# image name | ||
image: dc-backend | ||
|
||
# container name | ||
container_name: backend | ||
|
||
networks: | ||
- dc-network | ||
depends_on: | ||
- mongo | ||
|
||
environment: | ||
NODE_ENV: ${NODE_ENV} | ||
DB_USER: ${DB_USER:-backend} | ||
DB_PASSWORD: ${DB_PASSWORD:-password} | ||
DB_NAME: ${DB_NAME:-dc} | ||
DB_HOST: ${DB_HOST:-mongo} | ||
DB_PORT: ${DB_PORT:-27017} | ||
DB_REPLICA_SET: ${DB_REPLICA_SET:-dcrs} | ||
BACKEND_PORT: ${BACKEND_PORT:-3200} | ||
JWT_ACCESS_TOKEN_SECRET: ${JWT_ACCESS_TOKEN_SECRET:-backenddc2022} | ||
JWT_ACCESS_TOKEN_EXPIRATION_TIME: ${JWT_ACCESS_TOKEN_EXPIRATION_TIME:-900} | ||
JWT_REFRESH_TOKEN_SECRET: ${JWT_REFRESH_TOKEN_SECRET:-backenddc2022refresh} | ||
JWT_REFRESH_TOKEN_EXPIRATION_TIME: ${JWT_REFRESH_TOKEN_EXPIRATION_TIME:-1} | ||
AZURE_CLIENT_ID: ${AZURE_CLIENT_ID} | ||
AZURE_CLIENT_SECRET: ${AZURE_CLIENT_SECRET} | ||
AZURE_TENANT_ID: ${AZURE_TENANT_ID} | ||
AZURE_ENABLE: ${AZURE_ENABLE} | ||
|
||
# restart strategy | ||
restart: unless-stopped | ||
|
||
volumes: | ||
- ./backend:/app/backend | ||
- /app/backend/node_modules | ||
|
||
command: yarn start:debug | ||
|
||
ports: | ||
- 3200:3200 | ||
# debugging port | ||
- 9229:9229 | ||
|
||
frontend: | ||
build: | ||
context: frontend # to start on frontend folder | ||
dockerfile: docker/dev/Dockerfile # path to dev Dockerfile | ||
args: | ||
- NEXT_PUBLIC_BACKEND_URL=${NEXT_PUBLIC_BACKEND_URL:-http://localhost:3200} | ||
- NEXT_PUBLIC_NEXTAUTH_URL=${NEXT_PUBLIC_NEXTAUTH_URL:-http://localhost:3000} | ||
- NEXT_PUBLIC_ENABLE_AZURE=${NEXT_PUBLIC_ENABLE_AZURE} | ||
|
||
# set image name | ||
image: dc-frontend | ||
|
||
# set container name | ||
container_name: frontend | ||
|
||
networks: | ||
- dc-network | ||
depends_on: | ||
- backend | ||
|
||
environment: | ||
NEXT_PUBLIC_BACKEND_URL: ${NEXT_PUBLIC_BACKEND_URL:-http://localhost:3200} | ||
BACKEND_URL: ${BACKEND_URL:-http://backend:3200} | ||
NEXTAUTH_URL: ${NEXTAUTH_URL:-http://localhost:3000} | ||
NEXT_PUBLIC_NEXTAUTH_URL: ${NEXT_PUBLIC_NEXTAUTH_URL:-http://localhost:3000} | ||
SECRET: ${SECRET:-56e9169e3383d4a73fef9e0b4a3ff4e2} | ||
NEXT_PUBLIC_EXPIRATION_TIME: ${NEXT_PUBLIC_EXPIRATION_TIME:-900} | ||
AZURE_CLIENT_ID: ${AZURE_CLIENT_ID} | ||
AZURE_CLIENT_SECRET: ${AZURE_CLIENT_SECRET} | ||
AZURE_TENANT_ID: ${AZURE_TENANT_ID} | ||
NEXT_PUBLIC_ENABLE_AZURE: ${NEXT_PUBLIC_ENABLE_AZURE} | ||
|
||
volumes: | ||
- ./frontend:/app/frontend | ||
- /app/frontend/node_modules | ||
|
||
# restart strategy | ||
restart: unless-stopped | ||
|
||
# set ports | ||
ports: | ||
- 3000:3000 | ||
|
||
mongo2: | ||
image: mongo | ||
restart: always | ||
container_name: mongo2 | ||
networks: | ||
- dc-network | ||
ports: | ||
- "27018:27017" | ||
entrypoint: "bash -c '/usr/bin/mongod --replSet $${MONGO_REPLICA_NAME} --journal --bind_ip_all'" | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: ${DB_ROOT_USER:-admin} | ||
MONGO_INITDB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-password} | ||
MONGO_INITDB_DATABASE: ${DB_NAME:-dc} | ||
MONGO_BACKEND_USER: ${DB_USER:-backend} | ||
MONGO_BACKEND_PASSWORD: ${DB_PASSWORD:-password} | ||
MONGO_REPLICA_NAME: ${DB_REPLICA_SET:-dcrs} | ||
mongo: | ||
image: mongo | ||
restart: always | ||
container_name: mongo | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
- ./database/rs-init.sh:/scripts/rs-init.sh | ||
networks: | ||
- dc-network | ||
links: | ||
- mongo2 | ||
command: "bash -c '/usr/bin/mongod --replSet $${MONGO_REPLICA_NAME} --journal --bind_ip_all'" | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: ${DB_ROOT_USER:-admin} | ||
MONGO_INITDB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-password} | ||
MONGO_INITDB_DATABASE: ${DB_NAME:-dc} | ||
MONGO_BACKEND_USER: ${DB_USER:-backend} | ||
MONGO_BACKEND_PASSWORD: ${DB_PASSWORD:-password} | ||
MONGO_REPLICA_NAME: ${DB_REPLICA_SET:-dcrs} | ||
|
||
# Networks | ||
networks: | ||
dc-network: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use Node image with version 16 | ||
FROM node:16-alpine | ||
|
||
# Container Dir | ||
WORKDIR /app/frontend | ||
|
||
# Copy package.json (to install all packages) | ||
COPY ./package.json . | ||
|
||
# Install the packages (on the package.json) | ||
RUN yarn install | ||
|
||
# Copy all files | ||
COPY ./ . | ||
|
||
# Export the port used by Next.js | ||
EXPOSE 3000 | ||
|
||
# Run uarn dev (as you do via terminal) | ||
CMD ["yarn", "dev"] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.