mirror of
https://github.com/detleph/server.git
synced 2026-09-04 00:26:03 +02:00
Dockerize the server
+ Add Dockerfile + Update 'server' docker-compose service
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
*.env
|
||||||
|
dist/
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
# Dockerfile for the event management server
|
||||||
|
|
||||||
|
FROM node:17-alpine3.12
|
||||||
|
|
||||||
|
# Create directory for the app
|
||||||
|
RUN mkdir /home/server
|
||||||
|
|
||||||
|
# Selectively copy the required files and directories
|
||||||
|
ADD prisma/ /home/app/prisma/
|
||||||
|
ADD scripts/ /home/app/scripts/
|
||||||
|
ADD src/ /home/app/src/
|
||||||
|
COPY package-lock.json /home/app
|
||||||
|
COPY package.json /home/app
|
||||||
|
COPY tsconfig.json /home/app
|
||||||
|
|
||||||
|
# Change directory into the container
|
||||||
|
WORKDIR /home/app
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN npm i -g typescript
|
||||||
|
RUN npm i
|
||||||
|
|
||||||
|
# Generate the prisma client
|
||||||
|
RUN npx prisma generate
|
||||||
|
|
||||||
|
# Compile TypeScript to JavaScript
|
||||||
|
RUN tsc
|
||||||
|
|
||||||
|
CMD ["sh", "scripts/docker-entrypoint.sh"]
|
||||||
+10
-4
@@ -18,7 +18,13 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
container_name: "postgres"
|
container_name: "postgres"
|
||||||
#server:
|
server:
|
||||||
# build: .
|
build: .
|
||||||
# restart: always
|
restart: always
|
||||||
# container_name: "server"
|
container_name: "server"
|
||||||
|
ports:
|
||||||
|
- ${PORT}:${PORT}
|
||||||
|
environment:
|
||||||
|
- PORT=${PORT}
|
||||||
|
- DATABASE_URL=${DATABASE_URL}
|
||||||
|
- 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