-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from bocabitlabs/develop
Use Docker Compose for the deployment
- Loading branch information
Showing
36 changed files
with
577 additions
and
809 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,80 @@ | ||
PYTHONPATH=${PYTHONPATH}:${PWD} | ||
# NGINX port where the application will listen for connections | ||
# Default: 8080 (integer) | ||
NGINX_PORT=8080 | ||
# List of allowed hosts to access the application | ||
# Default: 0.0.0.0,localhost | ||
ALLOWED_HOSTS=0.0.0.0,localhost,127.0.0.1 | ||
# Origins allowed by CORS to access the application API | ||
# Default: http://localhost:3000,http://127.0.0.1:3000 | ||
CORS_ALLOWED_ORIGINS = http://localhost:3000,http://127.0.0.1:3000 | ||
# Debug mode enabled | ||
# Default: true | ||
DEBUG=true | ||
# Log level | ||
# Default: "DEBUG" (Other options: "INFO", "WARNING", "ERROR", "CRITICAL") | ||
LOG_LEVEL=DEBUG | ||
# Whether or not to log to file | ||
# Default: false | ||
LOG_TO_FILE=false | ||
# Active handlers for the logger | ||
# Default: console. Other options: console,file | ||
LOGGER_HANDLERS=console | ||
# Path to the log files | ||
# Default: "". Other options: "/usr/src/logs/" | ||
LOGS_ROOT=/your/path/to/buho-stocks/data/ | ||
# Type of database | ||
# VALUES: sqlite | mysql | postgresql | ||
DB_TYPE=sqlite | ||
# MySQL root user password | ||
# Default: ex4mpl3 (string) | ||
DB_ROOT_PASSWORD=ex4mpl3 | ||
# Database name | ||
# Default: buho_stocks (string) | ||
DB_NAME=buho_stocks | ||
# Database user | ||
# Default: root (string) | ||
DB_USER=root | ||
# Database password | ||
# Default: example (string) | ||
DB_PASSWORD=example | ||
# Database hostname | ||
# Default: db (string) | ||
DB_HOSTNAME=db | ||
# Database port | ||
# Default: 3306 (integer) | ||
DB_PORT=3306 | ||
# Path of the database | ||
# Default: /your/path/to/buho-stocks/data/db.sqlite3 | ||
DATABASE_SQLITE_PATH=/your/path/to/buho-stocks/data/db.sqlite3 | ||
# Secret key for the application. Can be generated by os.urandom(20). | ||
# It is generated automatically when the container is created for the first time | ||
SECRET_KEY=REPLACE_SECRET_KEY | ||
# List of allowed hosts to access the application | ||
# Default: 0.0.0.0,localhost | ||
ALLOWED_HOSTS=0.0.0.0,localhost,127.0.0.1 | ||
# Path to the media files uploaded by the users | ||
# Default: /your/path/to/buho-stocks/media/ | ||
MEDIA_ROOT=/your/path/to/buho-stocks/media/ | ||
# Timezone of the application | ||
# Default: UTC | ||
TIME_ZONE=UTC | ||
# Enable or disable Sentry | ||
# Default: False | ||
ENABLE_SENTRY=false | ||
# Sentry DSN (Data Source Name) in order to send your errors to Sentry | ||
# Default: "" (string) | ||
SENTRY_DSN=https://[email protected]/1727901 | ||
# DO NOT EDIT FROM HERE. THESE VARIABLES ARE USED INTERNALLY BY THE APPLICATION | ||
# The following variables are populated from other variables | ||
# | ||
MARIADB_DATABASE=${DB_NAME} | ||
# | ||
# | ||
MARIADB_USER=${DB_USER} | ||
# | ||
# | ||
MARIADB_PASSWORD=${DB_PASSWORD} | ||
# | ||
# | ||
MARIADB_ROOT_PASSWORD=${DB_ROOT_PASSWORD} |
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: Docker Build & Publish | ||
on: | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
build-and-publish: | ||
name: Build and Publish Docker Image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and Push backend Docker Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . # Path to your Dockerfile and other build context files | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository }}:latest | ||
ghcr.io/${{ github.repository }}:${{ github.head_ref || github.ref_name }} | ||
labels: | | ||
org.opencontainers.image.source=https://github.com/bocabitlabs/${{ github.repository }} | ||
- name: Build and Push client Docker Image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . # Path to your Dockerfile and other build context files | ||
file: docker.client.Dockerfile | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository }}-client:latest | ||
ghcr.io/${{ github.repository }}-client:${{ github.head_ref || github.ref_name }} | ||
labels: | | ||
org.opencontainers.image.source=https://github.com/bocabitlabs/${{ github.repository }} |
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 |
---|---|---|
@@ -1,35 +1,28 @@ | ||
FROM tiangolo/uwsgi-nginx:python3.10 | ||
FROM python:3.10-slim | ||
|
||
RUN apt-get update | ||
RUN apt-get -y install curl gnupg | ||
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - | ||
RUN apt-get -y install nodejs | ||
|
||
VOLUME /usr/src/data | ||
VOLUME /usr/src/media | ||
|
||
RUN npm install --global yarn | ||
|
||
# set work directory | ||
WORKDIR /usr/src/app | ||
|
||
# set environment variables | ||
ENV PYTHONPATH "${PYTHONPATH}:/usr/src" | ||
ENV PIP_DISABLE_PIP_VERSION_CHECK 1 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV PYTHONPATH "${PYTHONPATH}:/usr/src" | ||
ENV LISTEN_PORT 34800 | ||
ENV UWSGI_INI /usr/src/uwsgi.ini | ||
# The following environment variables are used by Poetry to install dependencies | ||
|
||
ENV POETRY_VERSION 1.5.0 | ||
ENV POETRY_HOME /opt/poetry | ||
ENV POETRY_VIRTUALENVS_IN_PROJECT true | ||
ENV POETRY_CACHE_DIR ${WORKING_DIR}/.cache | ||
ENV VIRTUAL_ENVIRONMENT_PATH ${WORKING_DIR}/.venv | ||
ENV POETRY_CACHE_DIR ${WORKDIR}/.cache | ||
ENV VIRTUAL_ENVIRONMENT_PATH ${WORKDIR}/.venv | ||
|
||
LABEL org.opencontainers.image.authors='[email protected]' \ | ||
org.opencontainers.image.url='https://github.com/bocabitlabs/buho-stocks/pkgs/container/buho-stocks' \ | ||
org.opencontainers.image.documentation='https://bocabitlabs.github.io/buho-stocks/' \ | ||
org.opencontainers.image.source="https://github.com/bocabitlabs/buho-stocks" \ | ||
org.opencontainers.image.vendor='Bocabitlabs (Rene Fernandez)' \ | ||
org.opencontainers.image.licenses='GPL-3.0-or-later' | ||
|
||
COPY ./uwsgi.ini /usr/src/uwsgi.ini | ||
COPY ./nginx-app.conf /etc/nginx/conf.d/custom.conf | ||
COPY ./prestart.sh /app/prestart.sh | ||
# Required to have netcat-openbsd | ||
RUN apt-get update | ||
RUN apt-get install default-libmysqlclient-dev netcat-openbsd gcc -y | ||
|
||
# Install Poetry and dependencies | ||
COPY pyproject.toml ./ | ||
|
@@ -38,29 +31,11 @@ COPY poetry.lock ./ | |
# Using Poetry to install dependencies without requiring the project main files to be present | ||
RUN pip install poetry==${POETRY_VERSION} && poetry install --only main --no-root --no-directory | ||
|
||
WORKDIR /usr/src/client | ||
COPY ./client/package.json /usr/src/client/package.json | ||
COPY ./client/yarn.lock /usr/src/client/yarn.lock | ||
COPY ./client/yarn.lock /usr/src/client/vite.config.ts | ||
RUN yarn --production --pure-lockfile | ||
COPY ./client /usr/src/client | ||
|
||
RUN yarn build | ||
RUN rm -rf /usr/src/client/node_modules/ | ||
RUN mkdir /app/frontend/ | ||
RUN mv ./dist/* /app/frontend/ | ||
|
||
WORKDIR /usr/src/app | ||
COPY ./backend /usr/src/app | ||
|
||
RUN mkdir /usr/src/media/ | ||
RUN mkdir /usr/src/logs/ | ||
# copy project | ||
COPY ./backend/config/config.sample.py /usr/src/app/config/config.py | ||
|
||
EXPOSE 34800 | ||
COPY ./backend $WORKDIR | ||
COPY ./etc /usr/src/etc | ||
|
||
RUN poetry run python manage.py collectstatic | ||
RUN sed -i -e "s/REPLACE_SECRET_KEY/$(od -x /dev/urandom | head -1 | awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}')/g" /usr/src/app/config/config.py | ||
RUN chmod +x /usr/src/etc/entrypoint.sh | ||
|
||
EXPOSE 8000 | ||
|
||
ENTRYPOINT ["/usr/src/etc/entrypoint.sh"] |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.