Skip to content

Commit

Permalink
#162 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pfwd committed Nov 6, 2022
1 parent 6ee7b98 commit 9e5551c
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 3 deletions.
9 changes: 8 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ services:

website:
build:
dockerfile: Dockerfile
dockerfile: Dockerfile.dev
context: ./website/
networks:
- code_quiz
restart: always
volumes:
- ./website:/app
- /app/node_modules
- /app/.next
ports:
- "3000:3000"

api:
build:
Expand Down
3 changes: 2 additions & 1 deletion website/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ EXPOSE 3000

ENV PORT 3000

CMD ["node", "server.js"]
CMD ["node", "server.js"]

24 changes: 24 additions & 0 deletions website/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ARG NODE_ENV=dev
NODE_ENV=${NODE_ENV}

FROM node:16-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

COPY package.json yarn.lock* ./

COPY ./infra/docker/scripts ./scripts
RUN chmod +x -Rv ./scripts/
RUN ./scripts/yarn_install.sh
# The below install script will be replaced by yarn_install.sh
RUN yarn install

COPY . .

EXPOSE 3000
ENV PORT 3000

# The below will be replaced by the entry point
CMD ["yarn", "dev"]

ENTRYPOINT ./scripts/entry_point.sh
10 changes: 10 additions & 0 deletions website/infra/docker/scripts/entry_point.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
print "ENV mode = ${NODE_ENV}"

# IF NODE_ENV === 'PRODUCTION'
print "Running production build"
yarn build
node server.js

# IF NODE_ENV === 'DEV'
print "Running dev mode for hot reloading"
yarn dev
13 changes: 13 additions & 0 deletions website/infra/docker/scripts/yarn_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

printf "Moving into /app"
cd /app

print "ENV mode = ${NODE_ENV}"

# IF NODE_ENV === 'PRODUCTION'
print "Installing from frozen lockfile"
yarn --frozen-lockfile

# IF NODE_ENV === 'DEV'
print "Installing yarn deps"
yarn install
2 changes: 1 addition & 1 deletion website/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Home: NextPage = () => {

<main className={styles.main}>
<h1 className={styles.title}>
Welcome to <a href="https://nextjs.org">Next.js!</a>
Welcome to <a href="https://nextjs.org">Code Quiz!</a>
</h1>

<p className={styles.description}>
Expand Down

0 comments on commit 9e5551c

Please sign in to comment.