Skip to content

Commit

Permalink
Merge pull request #33 from CS3219-AY2425S1/titus/fix-docker
Browse files Browse the repository at this point in the history
fix: docker setup
  • Loading branch information
UnwilledTangent authored Oct 6, 2024
2 parents 2a15e89 + 4b788f1 commit 65f0d57
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 17 deletions.
3 changes: 0 additions & 3 deletions apps/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ services:
build:
context: ./user-service
dockerfile: Dockerfile
args:
DB_CLOUD_URI: ${DB_CLOUD_URI}
JWT_SECRET: ${JWT_SECRET}
ports:
- 3001:3001
networks:
Expand Down
3 changes: 2 additions & 1 deletion apps/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ You can start editing the page by modifying `app/page.tsx`. The page auto-update
```sh
# Navigate to the frontend app directory
cd apps/frontend

# Build dockerfile (Ensure that your docker daemon is running beforehand)
docker build -t frontend -f Dockerfile .
```
Expand All @@ -52,7 +53,7 @@ Run the backend server locally and visit http://localhost:3000/ to see the front

```sh
# Run the docker image, the -d tag is to run it detached
docker run -p 3000:3000 -d frontend -e NEXT_PUBLIC_QUESTION_SERVICE_URL="http://localhost:8080/"
docker run -p 3000:3000 --env-file .env -d frontend

# To see the running container
docker ps
Expand Down
6 changes: 3 additions & 3 deletions apps/frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ export default function Home() {
}, [search]);

// Table column specification
var columns
var columns: TableProps<Question>["columns"]
if (isAdmin) {
var columns: TableProps<Question>["columns"] = [
columns = [
{
title: "Id",
dataIndex: "id",
Expand Down Expand Up @@ -437,7 +437,7 @@ export default function Home() {
},
];
} else {
var columns: TableProps<Question>["columns"] = [
columns = [
{
title: "Id",
dataIndex: "id",
Expand Down
1 change: 1 addition & 0 deletions apps/question-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ WORKDIR /usr/src/app

# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./

RUN go mod tidy && go mod download && go mod verify

COPY . .
Expand Down
2 changes: 1 addition & 1 deletion apps/question-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ docker build -t question-service .
```

```bash
docker run -p 8080:8080 -d question-service
docker run -p 8080:8080 --env-file .env -d question-service
```

The server will be available at http://localhost:8080.
Expand Down
6 changes: 0 additions & 6 deletions apps/user-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
FROM node:20-alpine AS base

ARG DB_CLOUD_URI
ARG JWT_SECRET
ENV DB_CLOUD_URI=${DB_CLOUD_URI}
ENV JWT_SECRET=${JWT_SECRET}
ENV ENV=PROD

FROM base AS deps

WORKDIR /app
Expand Down
7 changes: 4 additions & 3 deletions apps/user-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,16 @@
```bash
# Navigate to the user-service app directory
cd apps/user-service
# Build dockerfile after replacing the build arguments (Ensure that your docker daemon is running beforehand)
docker build -t user-service --build-arg JWT_SECRET='replace_with_jwt_secret' --build-arg DB_CLOUD_URI='replace_with_db_uri_here' -f Dockerfile .

# Build dockerfile (Ensure that your docker daemon is running beforehand)
docker build -t user-service -f Dockerfile .
```

### Running Docker

```bash
# Run the docker image, the -d tag is to run it detached
docker run -p 3001:3001 -d user-service
docker run -p 3001:3001 --env-file .env -d user-service

# To check the container information
docker ps
Expand Down

0 comments on commit 65f0d57

Please sign in to comment.