Skip to content

Commit

Permalink
Merge pull request #320 from ita-social-projects/#First-deploy
Browse files Browse the repository at this point in the history
#first deploy
  • Loading branch information
BelousSofiya authored Nov 20, 2023
2 parents 944b985 + 34582db commit 02fb084
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/django_cd_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
CORS_ORIGIN_WHITELIST: ${{ vars.CORS_ORIGIN_WHITELIST }}
REACT_APP_BASE_API_URL: ${{ vars.REACT_APP_BASE_API_URL }}
REACT_APP_PUBLIC_URL: ${{ vars.REACT_APP_PUBLIC_URL }}
ALLOWED_ENV_HOST: ${{ vars.ALLOWED_ENV_HOST }}

jobs:
deploy:
Expand All @@ -37,6 +38,10 @@ jobs:
run: docker compose -f docker-compose.dev.yml exec ${{ vars.API_DEV }} python manage.py migrate --noinput
- name: Docker compouse COLLECTSTATIC
run: docker compose -f docker-compose.dev.yml exec ${{ vars.API_DEV }} python manage.py collectstatic --no-input
- name: nginx
run: docker compose -f docker-compose.nginx.yml down -v
- name: nginx
run: docker compose -f docker-compose.nginx.yml up -d --build

- name: Clean up old docker resources
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests_be.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ env:
EMAIL_HOST_USER: [email protected]
EMAIL_HOST_PASSWORD: Test1234
CORS_ORIGIN_WHITELIST: ''
ALLOWED_ENV_HOST: ''


jobs:
build:
Expand Down
6 changes: 6 additions & 0 deletions FrontEnd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ WORKDIR /app
# Copy app files
COPY . .
# Install dependencies (npm ci makes sure the exact versions in the lockfile gets installed)
ARG REACT_APP_BASE_API_URL
ARG REACT_APP_PUBLIC_URL

ENV REACT_APP_BASE_API_URL=$REACT_APP_BASE_API_URL
ENV REACT_APP_PUBLIC_URL=$REACT_APP_PUBLIC_URL

RUN npm ci
# Build the app
RUN npm run build
Expand Down
12 changes: 8 additions & 4 deletions configs/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM nginx

RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d
FROM nginx:1.21.0-alpine as production
ENV NODE_ENV production
# Add your nginx.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion configs/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server {
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://frontend:80;
proxy_pass http://frontend;
proxy_redirect off;
}

Expand Down
4 changes: 3 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
build: .
container_name: api-dev
restart: on-failure
command: gunicorn forum.wsgi:application --bind 0.0.0.0:8000
command: gunicorn --log-level debug forum.wsgi:application --bind 0.0.0.0:8000
volumes:
# - ./:/Forum
- static:/home/forum/app/public/static
Expand All @@ -29,6 +29,7 @@ services:
- EMAIL_HOST_USER=${EMAIL_HOST_USER}
- EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD}
- CORS_ORIGIN_WHITELIST=${CORS_ORIGIN_WHITELIST}
- ALLOWED_ENV_HOST=${ALLOWED_ENV_HOST}
networks:
- forum_network
frontend:
Expand All @@ -37,6 +38,7 @@ services:
- static:/home/forum/app/public/static
environment:
- REACT_APP_BASE_API_URL=${REACT_APP_BASE_API_URL}
- REACT_APP_PUBLIC_URL=${REACT_APP_PUBLIC_URL}
ports:
- 3000:80
build:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
build: ./configs/nginx
container_name: nginx
ports:
- 8080:80
- 80:80
networks:
- forum_network
networks:
Expand Down
12 changes: 7 additions & 5 deletions forum/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
# ALLOWED_HOSTS = ['localhost', '127.0.0.1', '[::1]', '0.0.0.0']
ALLOWED_HOSTS = [
"localhost",
"127.0.0.1",
"[::1]",
"0.0.0.0",
config("ALLOWED_ENV_HOST"),
]

# Application definition

Expand Down Expand Up @@ -79,9 +84,6 @@
"http://0.0.0.0",
]

# For future:
# CORS_ORIGIN_WHITELIST = os.getenv('CORS_ORIGIN_WHITELIST').split(',')

CORS_ALLOW_HEADERS = list(default_headers) + [
"Access-Control-Expose-Headers",
"Access-Control-Allow-Headers",
Expand Down

0 comments on commit 02fb084

Please sign in to comment.