Skip to content

Commit

Permalink
🚚(docker) move frontend docker config
Browse files Browse the repository at this point in the history
Move frontend docker config to
src/frontend/Dockerfile.
  • Loading branch information
AntoLC committed Apr 15, 2024
1 parent f7466f1 commit 00b1598
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 60 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/docker-hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./src/frontend/Dockerfile
target: frontend-production
build-args: DOCKER_USER=${{ env.DOCKER_USER }}:-1000
push: ${{ github.event_name != 'pull_request' }}
Expand Down Expand Up @@ -107,7 +108,8 @@ jobs:
name: Build and push
uses: docker/build-push-action@v5
with:
context: ./src/frontend/
context: .
file: ./src/frontend/Dockerfile
target: y-webrtc-signaling
build-args: DOCKER_USER=${{ env.DOCKER_USER }}:-1000
push: ${{ github.event_name != 'pull_request' }}
Expand Down
49 changes: 0 additions & 49 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,6 @@ RUN apt-get update && \
apt-get -y upgrade && \
rm -rf /var/lib/apt/lists/*

### ---- Front-end dependencies image ----
FROM node:20 as frontend-deps

WORKDIR /deps

COPY ./src/frontend/package.json ./package.json
COPY ./src/frontend/yarn.lock ./yarn.lock
COPY ./src/frontend/apps/impress/package.json ./apps/impress/package.json
COPY ./src/frontend/packages/i18n/package.json ./packages/i18n/package.json
COPY ./src/frontend/packages/eslint-config-impress/package.json ./packages/eslint-config-impress/package.json

RUN yarn --frozen-lockfile

### ---- Front-end builder image ----
FROM node:20 as frontend-builder-1

WORKDIR /builder

COPY --from=frontend-deps /deps/node_modules ./node_modules
COPY ./src/frontend .

WORKDIR /builder/apps/impress

FROM frontend-builder-1 as frontend-builder-2

RUN yarn build


# ---- Front-end image ----
FROM nginxinc/nginx-unprivileged:1.25 as frontend-production

# Un-privileged user running the application
ARG DOCKER_USER
USER ${DOCKER_USER}

COPY --from=frontend-builder-2 \
/builder/apps/impress/out \
/usr/share/nginx/html

COPY ./src/frontend/apps/impress/conf/default.conf /etc/nginx/conf.d

# Copy entrypoint
COPY ./docker/files/usr/local/bin/entrypoint /usr/local/bin/entrypoint

ENTRYPOINT [ "/usr/local/bin/entrypoint" ]

CMD ["nginx", "-g", "daemon off;"]


# ---- Back-end builder image ----
FROM base as back-builder

Expand Down
4 changes: 2 additions & 2 deletions bin/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ docker_build(
docker_build(
'localhost:5001/impress-frontend:latest',
context='..',
dockerfile='../Dockerfile',
dockerfile='../src/frontend/Dockerfile',
build_args={'ENV': 'dev'},
only=['./src/frontend', './src/mail', './docker'],
target = 'frontend-builder-1',
target = 'impress',
live_update=[
sync('./src/frontend', '/builder'),
]
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ services:

y-webrtc-signaling:
build:
context: ./src/frontend/
context: .
dockerfile: ./src/frontend/Dockerfile
target: y-webrtc-signaling
restart: unless-stopped
ports:
Expand Down
51 changes: 44 additions & 7 deletions src/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
FROM node:20-alpine as y-webrtc-signaling
FROM node:20 as frontend-deps

WORKDIR /home/frontend/

COPY ./package.json .
COPY ./apps/y-webrtc-signaling/package.json ./apps/y-webrtc-signaling/
COPY ./packages/eslint-config-impress/package.json ./packages/eslint-config-impress/
COPY ./src/frontend/package.json ./package.json
COPY ./src/frontend/yarn.lock ./yarn.lock
COPY ./src/frontend/apps/impress/package.json ./apps/impress/package.json
COPY ./src/frontend/apps/y-webrtc-signaling/package.json ./apps/y-webrtc-signaling/package.json
COPY ./src/frontend/packages/i18n/package.json ./packages/i18n/package.json
COPY ./src/frontend/packages/eslint-config-impress/package.json ./packages/eslint-config-impress/package.json

RUN yarn install
RUN yarn install --frozen-lockfile

COPY . .
COPY ./src/frontend/ .

# Copy entrypoint
COPY ./docker/files/usr/local/bin/entrypoint /usr/local/bin/entrypoint

# ---- y-webrtc-signaling ----
FROM frontend-deps as y-webrtc-signaling

# Un-privileged user running the application
ARG DOCKER_USER
USER ${DOCKER_USER}

WORKDIR /home/frontend/apps/y-webrtc-signaling
RUN yarn build

ENTRYPOINT [ "/usr/local/bin/entrypoint" ]

CMD ["yarn", "start"]

### ---- Front-end builder image ----
FROM frontend-deps as impress

WORKDIR /home/frontend/apps/impress
RUN yarn build

CMD ["yarn", "start"]
# ---- Front-end image ----
FROM nginxinc/nginx-unprivileged:1.25 as frontend-production

# Un-privileged user running the application
ARG DOCKER_USER
USER ${DOCKER_USER}

COPY --from=impress \
/home/frontend/apps/impress/out \
/usr/share/nginx/html

COPY ./src/frontend/apps/impress/conf/default.conf /etc/nginx/conf.d

ENTRYPOINT [ "/usr/local/bin/entrypoint" ]

CMD ["nginx", "-g", "daemon off;"]

0 comments on commit 00b1598

Please sign in to comment.