Skip to content

Commit d4db618

Browse files
committed
Add docker-compose.yaml
1 parent a8cd231 commit d4db618

File tree

6 files changed

+34
-18
lines changed

6 files changed

+34
-18
lines changed

backend/.dockerignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dockerfile
2+
.dockerignore
3+
node_modules
4+
npm-debug.log
5+
README.md
6+
.git
7+
database.sqlite

backend/Dockerfile

-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ COPY package.json package-lock.json ./
55
RUN npm ci
66
COPY . .
77

8-
ENV FRONTEND_ORIGIN=http://localhost:8000
9-
ENV PORT=8001
10-
118
EXPOSE $PORT
12-
139
RUN npx sequelize db:migrate
14-
RUN echo "Migration complete."
1510

1611
CMD ["node", "index.js"]

backend/config/config.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"development": {
33
"dialect": "sqlite",
4-
"storage": "database.sqlite"
4+
"storage": "database/database.sqlite"
55
},
66
"test": {
77
"dialect": "sqlite",
8-
"storage": "database.test.sqlite"
8+
"storage": "database/database.sqlite"
99
},
1010
"production": {
1111
"dialect": "sqlite",
12-
"storage": "database.production.sqlite"
12+
"storage": "database/database.sqlite"
1313
}
1414
}

backend/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ app.use(express.static(path.join(__dirname, 'public')));
2121
// init sequalize
2222
const sequelize = new Sequelize({
2323
dialect: 'sqlite',
24-
storage: 'database.sqlite',
24+
storage: 'database/database.sqlite',
2525
});
2626

2727
// "/"

docker-compose.yaml

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
1-
version: '3'
1+
version: '3.8'
2+
23
services:
4+
backend:
5+
image: unittcms-backend:latest
6+
build:
7+
context: ./backend
8+
ports:
9+
- '8001:8001'
10+
environment:
11+
- NODE_ENV=production
12+
- FRONTEND_ORIGIN=http://localhost:8000
13+
- PORT=8001
14+
volumes:
15+
- db-data:/app/database
16+
317
frontend:
18+
image: unittcms-frontend:latest
419
build:
520
context: ./frontend
621
ports:
722
- '8000:8000'
23+
environment:
24+
- NODE_ENV=production
25+
- NEXT_PUBLIC_BACKEND_ORIGIN=http://localhost:8001
26+
- PORT=8000
827
depends_on:
928
- backend
10-
backend:
11-
build:
12-
context: ./backend
13-
ports:
14-
- '8001:8001'
29+
30+
volumes:
31+
db-data:

frontend/Dockerfile

-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ RUN \
3838
FROM base AS runner
3939
WORKDIR /app
4040

41-
ENV NODE_ENV production
4241
# Uncomment the following line in case you want to disable telemetry during runtime.
4342
# ENV NEXT_TELEMETRY_DISABLED 1
4443

@@ -60,8 +59,6 @@ USER nextjs
6059

6160
EXPOSE 8000
6261

63-
ENV PORT 8000
64-
6562
# server.js is created by next build from the standalone output
6663
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
6764
CMD HOSTNAME="0.0.0.0" node server.js

0 commit comments

Comments
 (0)