-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed the configurations * Updated docker-compose.yml and added PostgreSQL docker setup * Added dockerfile for production client, added nginx configuration, fixed dockerfile for backend * Added github workflow * Updated README.md
- Loading branch information
Showing
16 changed files
with
223 additions
and
22 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
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,49 @@ | ||
name: Build, Test, and Push Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Test API | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Run tests | ||
run: docker-compose run --rm api sh -c "pytest /api/tests" | ||
|
||
build-and-push: | ||
name: Build and Push Docker Image | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build client image | ||
run: docker build -f client/Dockerfile-prod -t 17021702/webeye-client:latest client/ | ||
|
||
- name: Build API image | ||
run: docker build -t 17021702/webeye-api:latest ./api | ||
|
||
- name: Push client image | ||
run: docker push 17021702/webeye-client:latest | ||
|
||
- name: Push API image | ||
run: docker push 17021702/webeye-api: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
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
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
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 @@ | ||
FROM node:20-alpine AS build | ||
|
||
WORKDIR /client | ||
|
||
COPY . . | ||
|
||
RUN npm install && npm run build | ||
|
||
FROM nginx:alpine | ||
|
||
COPY --from=build /client/dist /usr/share/nginx/html | ||
|
||
COPY nginx.conf /etc/nginx/nginx.conf | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
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,43 @@ | ||
user nginx; | ||
|
||
worker_processes auto; | ||
|
||
events { worker_connections 1024; } | ||
|
||
http { | ||
server { | ||
server_tokens off; | ||
|
||
listen 8080; | ||
root /usr/share/nginx/html; | ||
include /etc/nginx/mime.types; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.html; | ||
} | ||
|
||
gzip on; | ||
gzip_vary on; | ||
gzip_http_version 1.0; | ||
gzip_comp_level 5; | ||
gzip_types | ||
application/atom+xml | ||
application/javascript | ||
application/json | ||
application/rss+xml | ||
application/vnd.ms-fontobject | ||
application/x-font-ttf | ||
application/x-web-app-manifest+json | ||
application/xhtml+xml | ||
application/xml | ||
font/opentype | ||
image/svg+xml | ||
image/x-icon | ||
text/css | ||
text/plain | ||
text/x-component; | ||
gzip_proxied no-cache no-store private expired auth; | ||
gzip_min_length 256; | ||
gunzip on; | ||
} | ||
} |
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,58 @@ | ||
version: "3.9" | ||
|
||
services: | ||
api: | ||
image: 17021702/webeye-api | ||
restart: always | ||
ports: | ||
- "8000:8000" | ||
environment: | ||
- REDIS_USER=${REDIS_USER} | ||
- REDIS_HOST=${REDIS_HOST} | ||
- REDIS_PORT=${REDIS_PORT} | ||
- REDIS_PASSWORD=${REDIS_PASSWORD} | ||
- POSTGRES_USER=${POSTGRES_USER} | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
- POSTGRES_DB=${POSTGRES_DB} | ||
- POSTGRES_HOST=${POSTGRES_HOST} | ||
- SMTP_HOST=${SMTP_HOST} | ||
- SMTP_PORT=${SMTP_PORT} | ||
- SMTP_USER=${SMTP_USER} | ||
- SMTP_PASSWORD=${SMTP_PASSWORD} | ||
|
||
client: | ||
image: 17021702/webeye-client | ||
ports: | ||
- "80:8080" | ||
volumes: | ||
- ./client/nginx.conf:/etc/nginx/nginx.conf | ||
|
||
# You can also use Docker containers for PostgreSQL and Redis instead of using serverless solutions | ||
# postgres-db: | ||
# build: | ||
# context: ./postgres | ||
# ports: | ||
# - "5432:5432" | ||
# volumes: | ||
# - postgres-data:/var/lib/postgresql/data | ||
# healthcheck: | ||
# test: ["CMD-SHELL", "pg_isready -U devuser -d postgres"] | ||
# interval: 1s | ||
# timeout: 1s | ||
# retries: 60 | ||
# | ||
# redis: | ||
# image: redis:7.0-alpine | ||
# ports: | ||
# - "6379:6379" | ||
# volumes: | ||
# - redis-data:/data | ||
# healthcheck: | ||
# test: redis-cli ping | ||
# interval: 1s | ||
# timeout: 1s | ||
# retries: 60 | ||
# | ||
#volumes: | ||
# postgres-data: | ||
# redis-data: |
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,8 @@ | ||
FROM postgres:16.1-alpine | ||
|
||
ENV POSTGRES_USER=devuser | ||
ENV POSTGRES_PASSWORD=changeme | ||
|
||
COPY init.sql /docker-entrypoint-initdb.d/ | ||
|
||
EXPOSE 5432 |
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,7 @@ | ||
-- Create main development database | ||
CREATE DATABASE devdb; | ||
GRANT ALL PRIVILEGES ON DATABASE devdb TO devuser; | ||
|
||
-- Create test database | ||
CREATE DATABASE webeye_test_db; | ||
GRANT ALL PRIVILEGES ON DATABASE webeye_test_db TO devuser; |