Skip to content

Commit

Permalink
feat: improve deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
owalid committed Oct 26, 2023
1 parent 85a9d7f commit 4f3cc7c
Show file tree
Hide file tree
Showing 4 changed files with 48,145 additions and 6,602 deletions.
36 changes: 24 additions & 12 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
name: Deploy api to scaleway.
name: Deploy to scaleway.


# Run workflow on every push to master branch.
on:
push:
branches: [main]

# Your workflows jobs.
jobs:
deploy_scw:
runs-on: ubuntu-latest
steps:
# Check-out your repository.
- name: Checkout
uses: actions/checkout@v2

- name: Login to scaleway
run: docker login rg.fr-par.scw.cloud/my-services -u nologin --password-stdin <<< ${{ secrets.SCW_SECRET_KEY }}

- name: Docker build
run: docker build -t adaptaviz-fr:latest -f Dockerfile.prod .
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64'

- name: Docker tag
run: docker tag adaptaviz-fr:latest rg.fr-par.scw.cloud/my-services/adaptaviz-fr:latest
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker push in namespace
run: docker push rg.fr-par.scw.cloud/my-services/adaptaviz-fr:latest
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: rg.fr-par.scw.cloud/my-services
username: nologin
password: ${{ secrets.SCW_SECRET_KEY }}

# Build the images
- name: Build and push docker
uses: docker/build-push-action@v5
with:
push: true
file: ./Dockerfile.prod
tags: rg.fr-par.scw.cloud/my-services/adaptaviz-fr:latest
platforms: linux/arm64
cache-from: type=gha,mode=max
cache-to: type=gha,mode=max
24 changes: 13 additions & 11 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@ FROM node:17.2-alpine
RUN apk update

ARG user=app_user
ARG home=/home/$user
RUN mkdir -p $home
RUN addgroup -S app_group && adduser -S app_user -G app_group
WORKDIR $home
ARG home=/home/app_user
RUN mkdir -p /home/app_user && \
addgroup -S app_group && \
adduser -S app_user -G app_group

USER $user
WORKDIR /home/app_user

COPY --chown=$user . $home
USER app_user

COPY --chown=app_user . /home/app_user

RUN rm -rf /home/app/score

ENV HOST 0.0.0.0
ENV NUXT_HOST 0.0.0.0
ENV NODE_OPTIONS --max-old-space-size=5120 --openssl-legacy-provider
ENV NPM_CONFIG_PRODUCTION false
ENV NUXT_BASE_API_URL https://www.adaptaviz.fr/api

RUN npm install
RUN npm run build
ENV NUXT_BASE_API_URL https://adaptaviz.fr/api

USER $user
RUN npm install && \
npm run build && \
npm prune --production && \
npm cache clean --force

CMD ["npm", "start"]
Loading

0 comments on commit 4f3cc7c

Please sign in to comment.