Skip to content

Commit 7dba340

Browse files
committed
heroku docker changes
1 parent 110ecf3 commit 7dba340

File tree

5 files changed

+54
-12
lines changed

5 files changed

+54
-12
lines changed

Diff for: Dockerfile.hub

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ COPY ./frontend ./frontend
1313
# Build the code
1414
RUN cd ./frontend && npm run build
1515

16-
# Replace the PORT env variable in the frontend server.js file generated by standalone build
17-
RUN sed -i 's/process\.env\.PORT/process.env.PORT_FRONTEND/g' /app/frontend/.next/standalone/server.js
16+
# Replace `process.env.PORT` with `process.env.PORT || process.env.PORT_FRONTEND` in the frontend server.js file generated by standalone build
17+
RUN sed -i 's/process\.env\.PORT/process.env.PORT || process.env.PORT_FRONTEND/g' /app/frontend/.next/standalone/server.js
1818

1919
#-------------------builderImportTool-------------------------
2020
FROM node:18-alpine AS builderImportTool

Diff for: docker-compose.heroku.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
services:
2+
import-tool-service:
3+
container_name: import-tool-service
4+
build:
5+
context: ./backend/import-tool
6+
dockerfile: Dockerfile
7+
image: redis-utilities-import-tool-amd64:latest # built image name
8+
platform: linux/amd64
9+
ports:
10+
- "${PORT_BACKEND}:${PORT_BACKEND}"
11+
env_file:
12+
- ./.env
13+
14+
frontend:
15+
container_name: frontend
16+
build:
17+
context: ./frontend/
18+
dockerfile: Dockerfile
19+
image: redis-utilities-frontend-amd64:latest # built image name
20+
platform: linux/amd64
21+
ports:
22+
- "${PORT_FRONTEND}:${PORT_FRONTEND}"
23+
env_file:
24+
- ./.env
25+
stdin_open: true # -i input flag
26+
tty: true # -t terminal flag
27+
depends_on:
28+
- import-tool-service

Diff for: frontend/Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ COPY . ./frontend
1313
# Build the code
1414
RUN cd ./frontend && npm run build
1515

16-
# Replace the PORT env variable in the frontend server.js file generated by standalone build
17-
RUN sed -i 's/process\.env\.PORT/process.env.PORT_FRONTEND/g' /app/frontend/.next/standalone/server.js
16+
# Replace `process.env.PORT` with `process.env.PORT || process.env.PORT_FRONTEND` in the frontend server.js file generated by standalone build
17+
RUN sed -i 's/process\.env\.PORT/process.env.PORT || process.env.PORT_FRONTEND/g' /app/frontend/.next/standalone/server.js
18+
1819

1920
#-------------------Final stage-------------------------
2021
FROM node:18-alpine

Diff for: frontend/src/app/import/page.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ const Page = () => {
145145
});
146146
if (result?.data) {
147147
setRedisConUrl(testRedisUrl);
148+
setTestRedisUrl(testRedisUrl.split('@')[1]); // prevent showing password part in UI
148149

149150
addToSet(setBodyClasses, IMPORT_ANIMATE_CSS.CHOOSE_UPLOAD_PATH);
150151

Diff for: readme.hub.md

+20-8
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,37 @@ docker push prasanrajpurohit/redis-utilities:0.2.0
3535
# first time setup
3636
brew tap heroku/brew && brew install heroku # For macOS
3737

38-
heroku login # web login
39-
heroku create redis-utilities # or create a new app `redis-utilities` by dashboard
38+
heroku login # triggers web login
39+
40+
# or create a new app by dashboard
41+
heroku create redis-utilities-import-tool
42+
heroku create redis-utilities-frontend
4043

4144
# informing Heroku that your app should be run using the container stack
42-
heroku stack:set container -a redis-utilities
45+
heroku stack:set container -a redis-utilities-import-tool
46+
heroku stack:set container -a redis-utilities-frontend
4347
```
4448

4549
```sh
4650
heroku container:login
4751

52+
# Build platform specific image
53+
docker-compose -f docker-compose.heroku.yml build
54+
4855
# Tag & Push the image to Heroku (appName/web):
49-
docker tag redis-utilities-amd64:latest registry.heroku.com/redis-utilities/web
50-
docker push registry.heroku.com/redis-utilities/web
56+
docker tag redis-utilities-import-tool-amd64:latest registry.heroku.com/redis-utilities-import-tool/web
57+
docker tag redis-utilities-frontend-amd64:latest registry.heroku.com/redis-utilities-frontend/web
58+
59+
docker push registry.heroku.com/redis-utilities-import-tool/web
60+
docker push registry.heroku.com/redis-utilities-frontend/web
5161

5262
# Release the image
53-
heroku container:release web -a redis-utilities
63+
heroku container:release web -a redis-utilities-import-tool
64+
# Add frontend env variables in heroku dashboard like IMPORT_TOOL_END_POINT="https://redis-utilities-import-tool-a67413fa5a22.herokuapp.com"
65+
heroku container:release web -a redis-utilities-frontend
5466

5567
# Just restart the app
56-
heroku restart -a redis-utilities
57-
heroku ps -a redis-utilities
68+
heroku restart -a redis-utilities-frontend
69+
heroku ps -a redis-utilities-frontend
5870

5971
```

0 commit comments

Comments
 (0)