mirror of
https://github.com/AudebertAdrien/ft_transcendence.git
synced 2025-12-16 14:07:49 +01:00
modified base files
This commit is contained in:
commit
c45509f543
@ -1,8 +0,0 @@
|
|||||||
docker-compose.yaml
|
|
||||||
Dockerfile
|
|
||||||
.dockerignore
|
|
||||||
.env
|
|
||||||
.git
|
|
||||||
.gitignore
|
|
||||||
makefile
|
|
||||||
venv
|
|
||||||
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,8 +1,7 @@
|
|||||||
|
.gitignore
|
||||||
.env
|
.env
|
||||||
|
docker-compose.yaml
|
||||||
# virtualenv
|
makefile
|
||||||
venv/
|
venv/
|
||||||
|
|
||||||
__pycache__
|
__pycache__
|
||||||
|
|
||||||
data/
|
data/
|
||||||
|
|||||||
10
Dockerfile
10
Dockerfile
@ -7,20 +7,12 @@ ENV PYTHONUNBUFFERED 1
|
|||||||
WORKDIR /transcendence
|
WORKDIR /transcendence
|
||||||
|
|
||||||
RUN apt update && apt upgrade -y
|
RUN apt update && apt upgrade -y
|
||||||
RUN apt install -y vim
|
|
||||||
|
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
|
COPY manage.py .
|
||||||
|
|
||||||
RUN python3 -m venv venv
|
RUN python3 -m venv venv
|
||||||
RUN venv/bin/pip3 install --upgrade pip
|
RUN venv/bin/pip3 install --upgrade pip
|
||||||
RUN venv/bin/pip3 install --no-cache-dir -r requirements.txt
|
RUN venv/bin/pip3 install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Collect static files during the build
|
|
||||||
RUN venv/bin/python manage.py collectstatic --noinput
|
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
# CMD ["venv/bin/python", "manage.py", "runserver", "0.0.0.0:80"]
|
|
||||||
CMD ["daphne", "-b", "0.0.0.0", "-p", "80", "pong.asgi:application"]
|
|
||||||
107
README.md
Normal file
107
README.md
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
# Installing Docker and Docker Compose on Ubuntu
|
||||||
|
|
||||||
|
This guide will help you install Docker and Docker Compose on an Ubuntu system.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- A system running Ubuntu (preferably 20.04 LTS or later)
|
||||||
|
- A user account with `sudo` privileges
|
||||||
|
|
||||||
|
## Installing Docker
|
||||||
|
|
||||||
|
1. **Update the package index:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt update
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Install required packages:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install apt-transport-https ca-certificates curl software-properties-common
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Add Docker's official GPG key:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Set up the Docker repository:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Update the package index again:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt update
|
||||||
|
```
|
||||||
|
|
||||||
|
6. **Install Docker CE:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install docker-ce
|
||||||
|
```
|
||||||
|
|
||||||
|
7. **Check the Docker service status:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo systemctl status docker
|
||||||
|
```
|
||||||
|
|
||||||
|
8. **Add your user to the `docker` group to run Docker commands without `sudo`:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo usermod -aG docker $USER
|
||||||
|
```
|
||||||
|
|
||||||
|
9. **Log out and log back in to apply the group changes.**
|
||||||
|
|
||||||
|
## Installing Docker Compose
|
||||||
|
|
||||||
|
1. **Download Docker Compose:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Apply executable permissions to the Docker Compose binary:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo chmod +x /usr/local/bin/docker-compose
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Verify the installation:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose --version
|
||||||
|
```
|
||||||
|
|
||||||
|
## Verifying Docker and Docker Compose Installation
|
||||||
|
|
||||||
|
1. **Run a simple Docker container:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run hello-world
|
||||||
|
```
|
||||||
|
|
||||||
|
This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message.
|
||||||
|
|
||||||
|
2. **Check Docker Compose version:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose --version
|
||||||
|
```
|
||||||
|
|
||||||
|
This command outputs the version of Docker Compose installed.
|
||||||
|
|
||||||
|
Congratulations! You have successfully installed Docker and Docker Compose on your Ubuntu system.
|
||||||
|
|
||||||
|
## Additional Resources
|
||||||
|
|
||||||
|
- [Docker Documentation](https://docs.docker.com/)
|
||||||
|
- [Docker Compose Documentation](https://docs.docker.com/compose/)
|
||||||
|
|
||||||
|
|
||||||
@ -29,9 +29,10 @@ services:
|
|||||||
command: /bin/sh -c "sleep 5 &&
|
command: /bin/sh -c "sleep 5 &&
|
||||||
venv/bin/python manage.py makemigrations --noinput &&
|
venv/bin/python manage.py makemigrations --noinput &&
|
||||||
venv/bin/python manage.py migrate --noinput &&
|
venv/bin/python manage.py migrate --noinput &&
|
||||||
|
venv/bin/python manage.py collectstatic --noinput &&
|
||||||
venv/bin/daphne -b 0.0.0.0 -p 80 pong.asgi:application"
|
venv/bin/daphne -b 0.0.0.0 -p 80 pong.asgi:application"
|
||||||
volumes:
|
volumes:
|
||||||
- ./pong:/transcendence/pong
|
- pong:/transcendence/pong
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
@ -53,6 +54,16 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
driver: local
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
device: ${POSTGRES_DATA_PATH}
|
||||||
|
o: bind
|
||||||
|
pong:
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
device: ${PROJECT_PATH}
|
||||||
|
o: bind
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
app-network:
|
app-network:
|
||||||
|
|||||||
15
env_template
Normal file
15
env_template
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Django settings
|
||||||
|
SECRET_KEY=
|
||||||
|
DEBUG=True
|
||||||
|
DJANGO_ALLOWED_HOSTS=['*']
|
||||||
|
|
||||||
|
# PostgreSQL settings
|
||||||
|
POSTGRES_DB=
|
||||||
|
POSTGRES_USER=
|
||||||
|
POSTGRES_PASSWORD=
|
||||||
|
|
||||||
|
DB_HOST=db
|
||||||
|
DB_PORT=5432
|
||||||
|
|
||||||
|
PROJECT_PATH=${PWD}/pong
|
||||||
|
POSTGRES_DATA_PATH=${PWD}/data/db
|
||||||
25
makefile
25
makefile
@ -1,25 +0,0 @@
|
|||||||
.PHONY: all build down clean logs
|
|
||||||
|
|
||||||
all: build
|
|
||||||
@echo "Building Docker images..."
|
|
||||||
@sudo mkdir -p data/db
|
|
||||||
@sudo docker compose -f ./docker-compose.yaml up --build
|
|
||||||
|
|
||||||
down:
|
|
||||||
@echo "Stopping Docker containers..."
|
|
||||||
@sudo docker compose -f ./docker-compose.yaml down
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@echo "Cleaning up Docker resources..."
|
|
||||||
@sudo docker stop $$(docker ps -qa) ;\
|
|
||||||
sudo docker rm $$(docker ps -qa) ;\
|
|
||||||
sudo docker rmi $$(docker image ls -q) ;\
|
|
||||||
sudo docker volume rm $$(docker volume ls -q) ;\
|
|
||||||
sudo docker network rm $$(docker network ls -q) ;\
|
|
||||||
sudo rm -rf data ;\
|
|
||||||
|
|
||||||
logs:
|
|
||||||
@echo "Displaying Docker logs..."
|
|
||||||
@sudo docker compose logs -f
|
|
||||||
|
|
||||||
re: down clean build
|
|
||||||
Loading…
x
Reference in New Issue
Block a user