Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suse delivery #408

Merged
merged 6 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 66 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
mix local.rebar --force
mix local.hex --force
mix deps.get
mix deps.compile --warnings-as-errors
mix deps.compile --warnings-as-errors
mix dialyzer --plt

static-code-analysis:
Expand Down Expand Up @@ -291,3 +291,68 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

obs-commit:
name: Commit the project on OBS
runs-on: ubuntu-20.04
if: github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
needs: [deps, static-code-analysis, test, test-e2e]
needs: [deps]
container:
image: ghcr.io/trento-project/continuous-delivery:master
env:
GITHUB_OAUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEST_FOLDER: "/tmp/osc_project"
NAME: trento-web-image
OBS_USER: ${{ secrets.OBS_USER }}
OBS_PASS: ${{ secrets.OBS_PASS }}
OBS_PROJECT: ${{ secrets.OBS_PROJECT }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup
run: |
ssl_verify=host zypper in -y wget unzip

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install assets
run: cd assets && npm install

- name: Get mix deps
run: mix local.hex --force && mix deps.clean --all && mix deps.get

- name: Set version
run: |
VERSION=$(./hack/get_version_from_git.sh)
sed -i 's~%%VERSION%%~'"${VERSION}"'~' Dockerfile

- name: Configure OSC
# OSC credentials must be configured beforehand as the HOME variables cannot be changed from /github/home
# that is used to run osc commands
run: |
/scripts/init_osc_creds.sh
mkdir -p $HOME/.config/osc
cp /root/.config/osc/oscrc $HOME/.config/osc

- name: Commit on OBS
run: |
OBS_PACKAGE=$OBS_PROJECT/$NAME
osc checkout $OBS_PACKAGE -o $DEST_FOLDER
cp -r packaging/suse/* $DEST_FOLDER
cp Dockerfile $DEST_FOLDER
tar --transform 's,^./,/web/,' -zcvf $DEST_FOLDER/web.tar.gz --exclude=./.git ./*
cd $DEST_FOLDER
osc ar
osc commit -m "New development version of $NAME released"
48 changes: 25 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
FROM opensuse/leap AS elixir-build
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN zypper -n addrepo https://download.opensuse.org/repositories/devel:/languages:/erlang/SLE_15_SP3/devel:languages:erlang.repo
RUN zypper -n --gpg-auto-import-keys ref -s
RUN zypper -n in elixir
COPY . /build
WORKDIR /build
ENV MIX_ENV=prod
RUN mix local.rebar --force \
&& mix local.hex --force \
&& mix deps.get

#!BuildTag: trento/trento-web:latest
#!BuildTag: trento/trento-web:%%VERSION%%
#!BuildTag: trento/trento-web:%%VERSION%%-build%RELEASE%
#!UseOBSRepositories

FROM registry.suse.com/bci/nodejs:16 AS assets-build
COPY --from=elixir-build /build /build
WORKDIR /build/assets
RUN npm install
FROM bci/nodejs:16 AS assets-build
ADD web.tar.gz /build/
WORKDIR /build/web/assets
RUN npm run tailwind:build
RUN npm run build

FROM elixir-build AS release
FROM suse/sle15:15.3 AS release
# FLAVOR defined in prjconf, e.g.
# BuildFlags: dockerarg:FLAVOR=Community
ARG FLAVOR=Community
# # Workaround for https://github.com/openSUSE/obs-build/issues/487
RUN zypper --non-interactive in sles-release
RUN zypper -n in elixir elixir-hex erlang-rebar3
COPY --from=assets-build /build /build
WORKDIR /build
WORKDIR /build/web/
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV MIX_ENV=prod
ENV MIX_HOME=/usr/bin
ENV FLAVOR="$FLAVOR"
RUN mix phx.digest
RUN mix release


FROM registry.suse.com/bci/bci-base:15.3 AS trento
FROM suse/sle15:15.3 AS trento
# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=com.suse.trento
LABEL org.opencontainers.image.source="https://github.com/trento-project/web"
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# tar is required by kubectl cp
RUN zypper -n in tar
WORKDIR /app
COPY --from=release /build/_build/prod/rel/trento .
COPY --from=release /build/web/_build/prod/rel/trento .
EXPOSE 4000/tcp
ENTRYPOINT ["/app/bin/trento"]
14 changes: 14 additions & 0 deletions hack/get_version_from_git.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
TAG=$( git tag | grep -E "[0-9]\.[0-9]\.[0-9]" | sort -rn | head -n1 )

if [ -n "${TAG}" ]; then
COMMITS_SINCE_TAG=$(git rev-list "${TAG}".. --count)
if [ "${COMMITS_SINCE_TAG}" -gt 0 ]; then
COMMIT_SHA=$(git show -s --format=%ct.%h HEAD)
SUFFIX="+git.dev${COMMITS_SINCE_TAG}.${COMMIT_SHA}"
fi
else
TAG="0"
fi

echo "${TAG}${SUFFIX}"
24 changes: 0 additions & 24 deletions packaging/suse/Dockerfile

This file was deleted.

4 changes: 4 additions & 0 deletions packaging/suse/_service
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<services>
<service mode="buildtime" name="docker_label_helper"/>
<service mode="buildtime" name="kiwi_metainfo_helper"/>
</services>