added docker but not working yet

This commit is contained in:
slawk0
2024-11-16 18:01:16 +01:00
parent 6f4867c7e8
commit f7dc369b64
9 changed files with 140 additions and 8 deletions

1
client/.dockerignore Normal file
View File

@@ -0,0 +1 @@
node_modules

View File

@@ -1 +1,2 @@
VITE_API_URL=http://localhost:5173
VITE_API_URL=http://localhost:5173
VITE_BASE_URL=http://localhost:5173

25
client/Dockerfile Normal file
View File

@@ -0,0 +1,25 @@
FROM node:18 AS builder
WORKDIR /app/client
COPY . .
# Install dependencies
RUN npm install
# Build the project
RUN npm run build
FROM nginx:alpine
# Remove the default Nginx configuration file
RUN rm /etc/nginx/conf.d/default.conf
# Copy the built files from the builder stage to the Nginx image
COPY --from=builder /app/client/dist /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Start Nginx in the foreground
CMD ["nginx", "-g", "daemon off;"]

17
client/nginx.conf Normal file
View File

@@ -0,0 +1,17 @@
server {
listen 80;
listen [::]:80;
server_name ${VITE_BASE_URL};
location /api {
proxy_pass ${VITE_API_URL};
include proxy_params;
}
root /app/client
location / {
try_files $uri /index.html;
}
}

View File

@@ -33,7 +33,7 @@
"postcss": "^8.4.47",
"prettier": "3.3.3",
"tailwindcss": "^3.4.13",
"typescript": "^5.5.3",
"typescript": "^5.6.3",
"typescript-eslint": "^8.0.1",
"vite": "^5.4.1"
}
@@ -4252,9 +4252,9 @@
}
},
"node_modules/typescript": {
"version": "5.6.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz",
"integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==",
"version": "5.6.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz",
"integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==",
"dev": true,
"license": "Apache-2.0",
"bin": {

View File

@@ -35,7 +35,7 @@
"postcss": "^8.4.47",
"prettier": "3.3.3",
"tailwindcss": "^3.4.13",
"typescript": "^5.5.3",
"typescript": "^5.6.3",
"typescript-eslint": "^8.0.1",
"vite": "^5.4.1"
}

43
docker-compose.yml Normal file
View File

@@ -0,0 +1,43 @@
services:
relay-server:
build:
context: ./server
dockerfile: Dockerfile
ports:
- "${SERVER_PORT}:${SERVER_PORT}"
# env_file:
# - .server/.env
environment:
SERVER_PORT: ${SERVER_PORT}
JWT_SECRET: ${JWT_SECRET}
ORIGIN: ${ORIGIN}
PG_USER: ${PG_USER}
PG_PASSWORD: ${PG_PASSWORD}
PG_DATABASE: ${PG_DATABASE}
PG_HOST: ${PG_HOST}
PG_PORT: ${PG_PORT}
depends_on:
- db
relay-client:
build:
context: ./client
dockerfile: Dockerfile
ports:
- "80:80"
db:
image: postgres:latest
# env_file:
# - .server/.env
environment:
POSTGRES_USER: ${PG_USER}
POSTGRES_PASSWORD: ${PG_PASSWORD}
POSTGRES_DB: ${PG_DATABASE}
volumes:
- postgres-data:/var/lib/postgresql/data
ports:
- "${PG_PORT}:${PG_PORT}"
volumes:
postgres-data:

34
server/.dockerignore Normal file
View File

@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
LICENSE
README.md

View File

@@ -5,5 +5,16 @@ ORIGIN=http://localhost:5173
PG_USER=postgres
PG_PASSWORD=haslo
PG_DATABASE=relay
PG_HOST=192.168.0.47
PG_PORT=5433
PG_HOST=db
PG_PORT=5433
#SERVER_PORT=3000
#JWT_SECRET=fdsfsdfds@
#ORIGIN=http://localhost:5173
#
#PG_USER=postgres
#PG_PASSWORD=haslo
#PG_DATABASE=relay
#PG_HOST=192.168.0.47
#PG_PORT=5433