mirror of
https://github.com/detleph/server.git
synced 2026-09-04 08:36:06 +02:00
Merge pull request #17 from detleph/feature-dockerize
Dockerize the server
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
*.env
|
||||
dist/
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
# Dockerfile for the event management server
|
||||
|
||||
FROM node:17-alpine3.12
|
||||
|
||||
# Create directory for the app
|
||||
RUN mkdir /app
|
||||
|
||||
# Copy dependency files
|
||||
COPY package.json package-lock.json /app
|
||||
|
||||
# Change directory into the container
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
RUN npm i -g typescript
|
||||
RUN npm i
|
||||
|
||||
# Selectively copy the required files and directories
|
||||
ADD prisma/ /app/prisma/
|
||||
ADD scripts/ /app/scripts/
|
||||
ADD src/ /app/src/
|
||||
COPY tsconfig.json /app
|
||||
|
||||
# Generate the prisma client
|
||||
RUN npx prisma generate
|
||||
|
||||
# Compile TypeScript to JavaScript
|
||||
RUN tsc
|
||||
|
||||
CMD ["sh", "scripts/docker-entrypoint.sh"]
|
||||
+12
-6
@@ -14,11 +14,17 @@ services:
|
||||
image: postgres
|
||||
restart: always
|
||||
environment:
|
||||
- POSTGRES_USER=server
|
||||
- POSTGRES_PASSWORD=${DATABASE_PASSWORD}
|
||||
ports:
|
||||
- 5432:5432
|
||||
container_name: "postgres"
|
||||
#server:
|
||||
# build: .
|
||||
# restart: always
|
||||
# container_name: "server"
|
||||
server:
|
||||
build: .
|
||||
restart: always
|
||||
container_name: "server"
|
||||
ports:
|
||||
- ${PORT:-3000}:${PORT:-3000}
|
||||
environment:
|
||||
- PORT=${PORT:-3000}
|
||||
- DATABASE_URL=postgresql://server:${DATABASE_PASSWORD}@postgres:5432/management?schema=public
|
||||
- DATABASE_USER=server
|
||||
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Entry point for docker
|
||||
|
||||
if ! test -f INITIALIZED; then
|
||||
# Migrate the database
|
||||
# TODO: Update to use prisma migrate
|
||||
npx prisma db push
|
||||
touch INITIALIZED
|
||||
fi
|
||||
|
||||
# Start the server
|
||||
node ./dist/app.js
|
||||
Reference in New Issue
Block a user