[Docker] Fix issues with PostgreSQL and move docker-compose file to root
This commit is contained in:
parent
c33f7974e4
commit
8e19811b0f
1
.docker/.gitignore
vendored
1
.docker/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
docker-compose.yml
|
|
@ -14,13 +14,14 @@ RUN apt-get update && apt-get install -y \
|
|||||||
libonig-dev \
|
libonig-dev \
|
||||||
libxml2-dev \
|
libxml2-dev \
|
||||||
zip \
|
zip \
|
||||||
unzip
|
unzip \
|
||||||
|
libpq-dev
|
||||||
|
|
||||||
# Clear cache
|
# Clear cache
|
||||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install PHP extensions
|
# Install PHP extensions
|
||||||
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
|
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd pgsql pdo_pgsql
|
||||||
|
|
||||||
# Get latest Composer
|
# Get latest Composer
|
||||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
@ -12,25 +12,30 @@
|
|||||||
1. Download the project repository via Git: `git clone https://git.alex.lol/FLOT/HovedprosjektWebApp.git /srv/FLOTWebApp`
|
1. Download the project repository via Git: `git clone https://git.alex.lol/FLOT/HovedprosjektWebApp.git /srv/FLOTWebApp`
|
||||||
2. Navigate to the repository directory: `cd /srv/FLOTWebApp`
|
2. Navigate to the repository directory: `cd /srv/FLOTWebApp`
|
||||||
3. Copy `.env.example` to `.env`. Leave the `.env` file as is for now.
|
3. Copy `.env.example` to `.env`. Leave the `.env` file as is for now.
|
||||||
4. Navigate to the `.docker` directory in the repository.
|
4. Copy `docker-compose.example.yml` to `docker-compose.yml`.
|
||||||
5. Copy `docker-compose.example.yml` to `docker-compose.yml`.
|
5. Edit `docker-compose.yml` (with your text editor) and modify configuration/volumes to match your needs.
|
||||||
6. Edit `docker-compose.yml` (with your text editor) and modify configuration/volumes to match your needs.
|
6. Edit `../.env` and modify your database credentials to match the ones you set in `docker-compose.yml`
|
||||||
7. Copy `nginx/hovedprosjekt.example.conf` to `nginx/hovedprosjekt.conf`.
|
|
||||||
8. Edit `nginx/hovedprosjekt.conf` and modify domain/TLS configuration to your needs.
|
|
||||||
- Make sure that the SSL certificate and key uses the path as the volume mapping in `docker-compose.yml`.
|
|
||||||
8. Edit `../.env` and modify your database credentials to match the ones you set in `docker-compose.yml`
|
|
||||||
- `DB_HOST` (db) and `DB_PORT` (5432) can generally be left as is
|
- `DB_HOST` (db) and `DB_PORT` (5432) can generally be left as is
|
||||||
9. Run `docker-compose build app`
|
7. Navigate to the `.docker` directory in the repository.
|
||||||
10. If built successfully, run `docker-compose up -d` to run all containers in "detached" mode.
|
8. Copy `examples/hovedprosjekt.example.conf` to `nginx/hovedprosjekt.conf`.
|
||||||
|
9. Edit `nginx/hovedprosjekt.conf` and modify domain/TLS configuration to your needs.
|
||||||
|
- Make sure that the SSL certificate and key uses the path as the volume mapping in `docker-compose.yml`.
|
||||||
|
10. Run `docker-compose build app`
|
||||||
|
11. If built successfully, run `docker-compose up -d` to run all containers in "detached" mode.
|
||||||
|
|
||||||
## Application setup - First-time setup only
|
## Application setup - First-time setup only
|
||||||
|
|
||||||
These steps should be run after you have run `docker-compose up -d`, as the containers need to be running.
|
These steps should be run after you have run `docker-compose up -d`, as the containers need to be running.
|
||||||
|
|
||||||
1. While still being in the `.docker` directory run: `docker-compose exec app composer install`
|
1. Go to the project repository: `cd /srv/FLOTWebApp`
|
||||||
|
2. Make sure that the project repository has correct permissions for the user specified in `docker-compose.yml`
|
||||||
|
- `sudo chown -R 1000: .` will set it to the user with ID "1000". You can see users and their IDs if you `cat /etc/passwd`.
|
||||||
|
3. While still being in the `.docker` directory run: `docker-compose exec app composer install`
|
||||||
- This will attach the `app` container and run the following command to install dependencies for the application: `composer install`
|
- This will attach the `app` container and run the following command to install dependencies for the application: `composer install`
|
||||||
- Dependency installation might take a while, so be patient.
|
- Dependency installation might take a while, so be patient.
|
||||||
2. Then run: `docker-compose exec app php artisan key:generate` to generate an app key that's saved in `.env`
|
4. Run `docker-compose exec app php artisan key:generate` to generate an app key that's saved in `.env`
|
||||||
|
5. Finally, create the database tables with: `docker-compose exec app php artisan migrate`
|
||||||
|
6. [Optional] Add sample users and posts to the database tables: `docker-compose exec app php artisan db:seed`
|
||||||
|
|
||||||
## Logs [Optional]
|
## Logs [Optional]
|
||||||
|
|
||||||
|
2
.docker/examples/.gitignore
vendored
Normal file
2
.docker/examples/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*.conf
|
||||||
|
!*.example.conf
|
4
.docker/nginx/.gitignore
vendored
4
.docker/nginx/.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
*.conf
|
*
|
||||||
!*.example.conf
|
!.gitignore
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,3 +10,4 @@ Homestead.json
|
|||||||
Homestead.yaml
|
Homestead.yaml
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
|
docker-compose.yml
|
||||||
|
@ -6,14 +6,14 @@ services:
|
|||||||
args:
|
args:
|
||||||
user: hovedprosjekt
|
user: hovedprosjekt
|
||||||
uid: 1000
|
uid: 1000
|
||||||
context: ./
|
context: ./.docker
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
image: hovedprosjekt
|
image: hovedprosjekt
|
||||||
container_name: hovedprosjekt-app
|
container_name: hovedprosjekt-app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
working_dir: /var/www/
|
working_dir: /var/www/
|
||||||
volumes:
|
volumes:
|
||||||
- ../:/var/www
|
- ./:/var/www
|
||||||
networks:
|
networks:
|
||||||
- hovedprosjekt
|
- hovedprosjekt
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ services:
|
|||||||
container_name: hovedprosjekt-db
|
container_name: hovedprosjekt-db
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_PASSWORD: FLOTHP_D8jqH4YjS4ajD4
|
POSTGRES_PASSWORD: FLOT_Hovedprosjekt
|
||||||
POSTGRES_USER: hovedprosjekt
|
POSTGRES_USER: hovedprosjekt
|
||||||
POSTGRES_DB: hovedprosjekt
|
POSTGRES_DB: hovedprosjekt
|
||||||
volumes:
|
volumes:
|
||||||
@ -38,8 +38,8 @@ services:
|
|||||||
- 80:80
|
- 80:80
|
||||||
- 443:443
|
- 443:443
|
||||||
volumes:
|
volumes:
|
||||||
- ../:/var/www
|
- ./:/var/www
|
||||||
- ./nginx/:/etc/nginx/conf.d/
|
- ./.docker/nginx/:/etc/nginx/conf.d/
|
||||||
- /srv/ssl:/srv/ssl
|
- /srv/ssl:/srv/ssl
|
||||||
networks:
|
networks:
|
||||||
- hovedprosjekt
|
- hovedprosjekt
|
Loading…
Reference in New Issue
Block a user