Skip to content

Commit

Permalink
Soroka 90 (#18)
Browse files Browse the repository at this point in the history
* fix: update all dependencies

* feat: add Dockerfile

* feat: build docker image on PR open/update

* feat: deploy stage on PR close

* feat: deploy prod on release

* fix: prod container build wrong path

* fix: build wit env and catch non-root path
  • Loading branch information
dice4x4 authored Jun 29, 2022
1 parent 4620750 commit f8a335f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
build-args:
REACT_APP_API_URL: ${{ env.REACT_APP_API_URL }}
target: prod
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand All @@ -68,7 +70,6 @@ jobs:
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker rm -f ${{ env.NAME }}
docker run -dp 8086:${{ env.SERVER_PORT }} --name ${{ env.NAME }} \
-e REACT_APP_API_URL=${{ env.REACT_APP_API_URL }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker logout
1 change: 0 additions & 1 deletion .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.pull_request.number }}
docker rm -f ${{ env.NAME }}
docker run -dp 8085:${{ env.SERVER_PORT }} --name ${{ env.NAME }} \
-e REACT_APP_API_URL=${{ env.REACT_APP_API_URL }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.pull_request.number }}
docker logout
3 changes: 3 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
REACT_APP_API_URL: https://soroka.f128.science/restapi/v1

jobs:

Expand Down Expand Up @@ -38,6 +39,8 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
build-args:
REACT_APP_API_URL=${{ env.REACT_APP_API_URL }}
target: prod
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM node:lts-alpine AS builder

ARG REACT_APP_API_URL
ENV REACT_APP_API_URL ${REACT_APP_API_URL}

WORKDIR /opt/app
COPY . /opt/app

Expand All @@ -10,9 +13,13 @@ RUN npm run build
FROM nginx:stable-alpine AS prod

COPY --from=builder /opt/app/build /usr/share/nginx/html
COPY default.conf /etc/nginx/conf.d/default.conf

FROM node:lts AS dev

ARG REACT_APP_API_URL
ENV REACT_APP_API_URL $REACT_APP_API_URL

WORKDIR /opt/app
COPY --from=builder /opt/app /opt/app

Expand Down
16 changes: 16 additions & 0 deletions default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {
listen 80;
listen [::]:80;
server_name localhost;

root /usr/share/nginx/html;
index index.html;

location / {
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

0 comments on commit f8a335f

Please sign in to comment.