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

PLAN-952 Add version to compilation process #1017

Draft
wants to merge 5 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ jobs:
DEVISE_SECRET=${{ env.DEVISE_SECRET }}
RAILS_ENV=production
NODE_ENV=development
PLANO_VERSION_FROM_BUILD=${{ github.ref_name }}
push: false
load: true
# target: development
Expand Down Expand Up @@ -153,6 +154,7 @@ jobs:
DEVISE_SECRET=${{ env.DEVISE_SECRET }}
RAILS_ENV=production
NODE_ENV=development
PLANO_VERSION_FROM_BUILD=${{ github.ref_name }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile-prod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ ENV BUNDLE_PATH /var/bundler

ARG DEVISE_SECRET

# The build of the docker file will set the ARG PLANO_VERSION_FROM_BUILD
ARG PLANO_VERSION_FROM_BUILD
# And we set the ENV in the Docker container with a default value
# based on PLANO_VERSION_FROM_BUILD
ENV PLANO_VERSION=${PLANO_VERSION_FROM_BUILD}

RUN apk add \
build-base \
freetds-dev \
Expand Down
35 changes: 35 additions & 0 deletions app/javascript/administration/about_link.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<div>
<b-button variant="link" class="text-light" v-b-modal.about-modal>About</b-button>
<b-modal id="about-modal" title="About" modal-class="about-modal" ok-only>
<p>Version: {{ version }}</p>
<p><a href="https://planoramaevents.github.io/planorama">About the Planorama Team &amp; Give Feedback</a></p>
</b-modal>
</div>
</template>

<script>
import settingsMixin from "@/store/settings.mixin";

export default {
name: "AboutLink",
mixins: [settingsMixin],
computed: {
email() {
return this.configByName('email_reply_to_address')
},
// Get the version from the runtime ENV which is set in the
// local env OR docker file. For deployments it comes from the docker
// file
version() {
return process.env.PLANO_VERSION;
}
}
}
</script>

<style lang="scss">
.help-modal .modal-md{
max-width: 20rem;
}
</style>
4 changes: 3 additions & 1 deletion app/javascript/navbar/top-navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<b-navbar-nav class="ml-auto">
<b-nav-form>
<help-link></help-link>
<a href="https://planoramaevents.github.io/planorama" target="_blank" class="btn btn-link text-light my-2 my-sm-0 mx-2">About</a>
<about-link></about-link>
<b-button v-if="loggedIn" @click="logout" variant="primary">Logout</b-button>
</b-nav-form>
</b-navbar-nav>
Expand All @@ -22,13 +22,15 @@
<script>
import { settingsMixin } from '@/mixins';
import HelpLink from '../administration/help_link.vue';
import AboutLink from '../administration/about_link.vue';
import authMixin from '../auth/auth.mixin';
import personSessionMixin from '../auth/person_session.mixin';

export default {
name: 'TopNavbar',
components: {
HelpLink,
AboutLink,
},
mixins: [
authMixin,
Expand Down
4 changes: 3 additions & 1 deletion config/webpack/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ environment.loaders.prepend('erb', erb)

var path = require('path');

// NOTE: this is the build env
environment.plugins.prepend('env',
new webpack.DefinePlugin({
'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'PLANO_VERSION': JSON.stringify(process.env.PLANO_VERSION)
})
)

Expand Down
18 changes: 18 additions & 0 deletions deploy_script_attempt_1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/bash

if [ $# -eq 0 ]; then
latest_tag=$(curl -s https://api.github.com/repos/PlanoramaEvents/planorama/releases/latest | jq -r '.tag_name')
export PLANO_VERSION=$latest_tag
elif [ $# -eq 1 ] && [ "$1" == "staging" ]; then
staging_tag=$(curl -s https://api.github.com/repos/PlanoramaEvents/planorama/releases | jq -r '.[0].tag_name')
export PLANO_VERSION=$latest_tag
elif [ $# -eq 1 ]; then
export PLANO_VERSION=$1
else
echo "Usage: $0 [staging,VERSION NUMBER]"
exit 1
fi

echo "Plano version: $PLANO_VERSION"
cd /opt/glasgow2024/app
/usr/bin/docker compose pull && /usr/bin/docker compose down && /usr/bin/docker compose up -d
82 changes: 82 additions & 0 deletions docker-compose-staging-prev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#
# This is sample docker file for use in a staging environment
#
# NOTE:
# You will need to create the pgdata and redis-data volumes:
# docker volume create --name=pgdata
# docker volume create --name=redis-data
#
version: '3.7'

volumes:
redis-data:
external: true
pgdata:
external: true

services:
redis:
image: redis:alpine
restart: always
volumes:
- redis-data:/data

postgres:
image: postgres:12-alpine
restart: always
env_file:
# NOTE: this will need to reflect local system
- "/opt/plano/etc/planorama.env"
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"

web:
command: "/opt/planorama/script/planorama_start.sh"
image: ghcr.io/planoramaevents/planorama:staging
ports:
- 3000:3000
volumes:
# NOTE: this will need to reflect local system
- /var/log/planorama/web:/opt/planorama/log
- type: tmpfs
target: /app/tmp
# NOTE: this will need to reflect local system
- /opt/plano/etc/planorama:/config
environment:
- PGID=1005
- PUID=1001
- RAILS_ENV=staging
- NODE_ENV=staging
env_file:
# NOTE: this will need to reflect local system
- "/opt/plano/etc/planorama.env"
depends_on:
- redis
- postgres
restart: always

planorama-sidekiq:
command: "/opt/planorama/script/planorama_sidekiq.sh"
image: ghcr.io/planoramaevents/planorama:staging
volumes:
# NOTE: this will need to reflect local system
- /var/log/planorama/sidekiq:/opt/planorama/log
- type: tmpfs
target: /app/tmp
# NOTE: this will need to reflect local system
- /opt/plano/etc/planorama:/config
environment:
- PGID=1005
- PUID=1001
- RAILS_ENV=staging
- NODE_ENV=staging
env_file:
# NOTE: this will need to reflect local system
- "/opt/plano/etc/planorama.env"
depends_on:
- redis
links:
- redis
restart: always