 Selamat tinggal, saya ialah Michael. Saya adalah... Seperti yang saya katakan, saya seorang perempuan sg. Sebenarnya... Saya akan berkongsi sedikit tentang apa yang kita lakukan. Satu-satunya perkara yang kita lakukan untuk ini. Sg Engeniasa adalah website yang mengenai perangkat yang berlaku di Singapura. Jadi, kita mengenai video yang kita gunakan online. Anda dapat periksa sg. Tapi hari ini, saya akan berkongsi sedikit tentang... ...berkongsi perangkat anda di permulaan. Jadi, saya belum membuat periksaan. Saya hanya mempunyai Google Doc dan saya harap anda dapat melihatnya... ...dan melihat note saya dari sana. Jadi, kenapa anda mahu melakukan perangkat di permulaan... ...semasa ada banyak pilihan di cloud? Sebenarnya, beberapa sebab saya telah melihat dalam masa lalu. Sebenarnya, beberapa sebab saya telah melihat di permulaan. Sebenarnya, yang pertama adalah sebab sekuriti. Sebenarnya, seseorang berkata, Hey, anda harus melihat... ...saya harus melihat informasi yang terkenal di permulaan. Dan tidak hanya informasi yang terkenal... ...saya dapat melihat di cloud. Jadi, bagaimanapun, di Singapura... ...saya mempunyai perangkat yang tidak terkenal... ...dan kelihatan, dan kelihatan. Jadi, bagi beberapa kelihatan sekuriti... ...saya juga mempunyai perangkatan... ...atau bagaimana anda dapat meletakkan informasi. Apabila anda melakukannya dengan data bank... ...data Banking, apabila banyak informasi pengguna... ...saya mungkin ingin melakukannya di permulaan... ...sebelum melakukannya di public cloud. Atau ia boleh menjadi kelihatan regulasi. Ada beberapa kelihatan dari... ...kalau ada bank... ...mungkin ada beberapa kelihatan monitor... ...atau anda perlu melakukannya di permulaan... ...dan anda dapat melakukannya di perangkat... ...dan sebagainya. Di perangkat, ia adalah perkara lain. Kadang-kadang, anda hanya ingin melakukannya... ...dan anda ingin melakukannya di permulaan... ...untuk memastikan tidak ada yang dapat melakukannya. Kadang-kadang, anda tidak ingin melakukannya di public cloud... ...atau di Heroku. Kadang-kadang, apabila anda melakukannya di public cloud... ...saya boleh menjadi lebih kelihatan. Apabila anda melakukannya di CPU... ...atau per jam, per minit... ...atau sebagainya. Apabila anda melakukannya di serverless... ...teknologi, anda boleh melakukannya per kedua... ...tapi secara kelihatan, anda melakukannya banyak. Apabila anda melakukannya dengan mempunyai data centre... ...atau di data centre, ia adalah sebuah kursus. Anda membuat kursus yang tersebut. Anda membuang masin ini dan... ...tidak ada kursus yang tidak ada diambil... ...sebelum elektrisiti. Apabila anda melakukannya di public cloud... ...atau anda melakukannya di dalam... ...selepas sejauh, anda melakukannya lebih... ...di public cloud dan membeli servis fisikal. Sebabnya, sebabnya anda mungkin mempunyai... ...atau di perusahaan saya yang tersebut... ...saya sudah mempunyai data centre sendiri. Dan mereka akan mempunyai data centre sendiri. Bagaimana anda membuat kursus di public cloud? Ya. Kadang-kadang, anda akan mengatakan... ...bukan pasti ia akan berjaya. Ada beberapa orang akan mengatakan... ...tapi public cloud... ...tapi kenapa anda membuat kursus ini? Dan kita dapat memperlukan banyak duit... ...untuk membuat kursus di public cloud. Jadi, ia ada beberapa sebab yang saya telah melihat. Saya tidak pasti jika anda telah melihat sebuah sebab lain... ...tapi ini adalah sebuah yang saya telah melihat. Jadi, jika anda membuat kursus di public cloud... ...di perusahaan... ...saya akan tanya kepada kami... ...berapa serius anda? Maksud saya, anda hanya... ...menjelaskan dan menjelaskan? Atau anda... ...atau anda sudah mempunyai idea... ...atau anda sudah menjelaskan... ...atau anda pasti anda ingin melakukan ini... ...dan ini adalah data produksi... ...tapi anda ingin memprodukkan. Jadi, hari ini... ...saya akan mengatakan lebih banyak... ...sebahagian eksperimen... ...sebab ia lebih banyak... ...tapi sebahagian lain... ...saya akan memperkenalkan Ruby dan Rails... ...untuk perusahaan anda atau perusahaan anda... ...untuk pertama kali... ...dan anda tidak mempunyai banyak pengalaman... ...atau anda hanya ingin membuat... ...memperkenalkan dan memperkenalkan MVP. Mereka ingin memperkenalkan sesuatu yang mudah... ...yang dapat memperkenalkan idea anda... ...dan kemudian untuk memberitahui... ...pengalaman yang anda dapat... ...memperkenalkan sesuatu yang mudah di Rails... ...dan orang dapat menggunakan itu. Jadi, ia adalah idea itu. Jadi, ya... ...atau di syarikat yang saya dulu... ...masukkan... ...Ruby... ...saya merupakan perkara eksperimen... ...sebab kita tidak mempunyai... ...saya memperkenalkan... ...saya memperkenalkan perkara... ...memperkenalkan perkara ini... ...punyai Pivotal Cloud Foundry... ...yang adalah... ...platform-platform-platform... ...tetika sebelum kita memperkenalkan... ...platform-platform-platform... ...kita mahu memperkenalkan... ...yang dapat kita membangun... ...masukkan aplikasi yang mudah... ...dan memperkenalkan bagaimana... ...mereka memperkenalkan itu. Jadi, ya... ...biasanya ketika anda memperkenalkan pemeriksaan... ...yang tidak ada cloud... ...tidak ada cloud... ...tidak ada cloud... ...berkawasan data yang anda dapat melalui... ...tidak ada auto-deployment... ...sebagainya. Jadi, terutama anda perlu membawanya sebagainya... ...tidak ada cloud... ...tidak perlu mengawal, bahawa anda tidak mempunyai cloud. Bagi ini... ...kalau anda melihat... ...berkenalkan reka... ...tidak ada pemeriksaan. Fika saya mengapa... bagaimana perkara lain yang memutuskan saya untuk melakukan yang terbaik sehingga saya dapat di sini. Kita sangat menggunakan perkara seperti GitHub, dan keadaan CII, atau CIRCL, dan keadaan perkara lain, semua keadaan, dan sebagainya. Kita akan mengambil semua perkara yang telah digunakan, sebabnya ia sangat mudah menggunakan. Tetapi pada perkembangan, kita menggunakan banyak perkara sendiri. Kamu perlu melakukan banyak perkara sendiri. Selepas itu, kenapa perkembangan kamu berada di perkembangan? Pertanyaan adalah, kamu menggunakan perkembangan virtual? Atau kamu perlu menggunakan perkembangan bagi perkembangan? Perkembangan perkembangan adalah sebagainya seperti perkembangan fisikal yang kamu perlu menggunakan untuk menggunakan perkembangan O.S. untuk menjadikannya dan sebagainya. Jadi, kamu perlu menggunakan perkembangan virtual. Kemudian, perkembangan adalah bagaimana kamu dapat mendapat keadaan? Bagaimana kamu menghubungi keadaan? Dan bagaimana kamu berguna menggunakan perkembangan virtual untuk kamu? Kamu perlu menggunakan perkembangan virtual dengan perkembangan IT untuk menggunakan perkembangan virtual. Kamu mungkin mahu mempunyai perkembangan fisikal. Kamu mahu mempunyai perkembangan virtual untuk membuat perkembangan virtual. Jadi, kamu dapat mengubah keadaan. Dan bahkan sebuah leon yang penuh berkuali dengan nama domain yang boleh kamu berusahkan. Jadi, secara dalam, kamu boleh mixedgurkan ke Keramu, memetik URL atau kamu dapat melihat ke dalam. Sebalik lagi, apa perkembangan operation? Apakah perkembangan operation yang kamu gunakan? Saya k sergeman itu mengenali bagaimana kamu akan melepaskan ruangan perkembangan danetician di sebuah mesin. So in many cases if it's a Linux server running Ubuntu or maybe Red Hat and you probably have a few things you can do. Next thing in mind is do you have internet connectivity. So for example if you're doing this on premise and your your machines have full access to the internet. So that means things like bundle install will come quite easily. Because as you're building an application on Ruby and on Rails you probably need to download a lot of gems. Ruby gems and stuff. So you probably need to you want to be able to have internet connection. And sometimes so you don't have direct internet connection you probably will have a proxy server. So if you have a fault proxy then you probably need to set some environment variables like say HTTP proc. Oops, what did I do? So HTTP proxy. So this is probably important to set up or HTTPS. So these are probably two things you want to set up in your environment so that you can actually go online. So let me just format this. Next thing you want to ask yourself, do you have root access? Do you have root access to the machine? Because in the server you probably need to install a fair bit of software. So you probably want to ask and make sure that you have some form of root access. Or maybe at least some sudo access so they can install software packages. Because a lot of Ruby packages, Ruby gems will probably require some native libraries. So you want to make sure that you have some form of access to be able to download or install additional packages that's needed. Like say if you're on red hat, you won't be able to do some RPM install or YUM install to install additional packages that's needed by some native packages needed for the gems. Next question in my mind would be do you have a budget? Do you have a budget? Is that a small claims purchase you need to do? Or is it some internal transfer of money so you can actually go about getting all this done? So up here are all the really administrative things you probably need to get clear before you want to jump into this. Next thing to do is probably if you're given a VM, it probably will be a Linux VM. So you probably want to find out how much you know about Linux server admin. So you probably need to figure out how to actually login using SSH and then change to the sudo user to do the install and packages. So as one website that I used to go to is called How to Forge. So How to Forge is quite helpful. It's like a bunch of online tutorials that teach you how to administer, how to go about administering, setting up your own Linux servers. And you'll see a lot of fabulous instructions on how to do stuff. So I recommend checking it out if you're really total nuked with managing your own Linux servers so that you can at least get some experience with that. Otherwise, you'll probably have to rely on some DevOps folks that can help you, who can sit with you and probably give you some advice on how to do stuff. So you've got your server, you've got your server figure out, you've got to use a VM, and you've picked up some basic Linux server admin commands. So next thing you want to do is now to actually start installing Ruby on this server. First up, you want to make sure you can install Ruby. And there are many ways to do it installing Ruby. Like how we do this on the local develop environment, we want to have some form of version management of Ruby. So you can also do the same thing with RVM. RVM has a package called Ubuntu RVM, which lets you install, it's like an installer. So you just run this installer and you can basically run and install RVM into your devin or Ubuntu users. So the instructions here are quite straightforward. As long as you have sudo access, you probably can install, you need to install some additional packages, and then you can do the RVM install. Once you have this installed, then you have Ruby in your machine. If you don't like RVM and you're not familiar with how to use RVM, there's also RVM. So you can use RVM to do the installation. So with RVM, there is an RVM installer package as well. So you can install both RVM installer and RVM doktor. So it's kind of both. And both of this does require you to have Git installed on the machine. So that's probably one of the first dependency to do, to install Git on the server that you're using. So you can just use Git straight up to just install RVM. So once you have RVM installed, you can switch to the user and then you can do stuff. There might be a situation where your DevOps folks or even your IT operations folks will tell you, hey, we only support Java on our server. Or you can only install Java there. So for those folks, you can actually try using JRuby. JRuby is basically Ruby running on the Java virtual machine. So Java runtime. What I like about JRuby is that it's just one single file. It's one single file you just need to download. And once you have this binary downloaded and put in the correct folder, you can basically start using JRuby. And I think the latest version supports up to Ruby 2.5, which is 5.5x, which is kind of nice. So yeah, so I've used this in one of my previous clients place. So basically, it's also quite a lockdown environment. And they basically have to... So the only thing you could install there was a Ruby package. And then we basically found that you could use JRuby. So another question you might also have is, what if you don't really have a Linux server, you only have a Windows server? So this is where it gets a bit trickier. So if you're on a Windows server, there are also some options you can try. As one is a Ruby installer for Windows. So you can use Ruby installer to kind of like... This is a package provided by the Ruby language maintainers. So you can use this to install Ruby on Windows. And then you can basically start running this on your Windows server. For example, if you are only given a virtual machine that runs Windows Server 2008 or something. So you probably want to use something like this. Of course, in a more modern system, you can also try and get the Windows sub-system for Linux installed as well. So I'll share this... Wait, let me share this Google Doc. If you can... Let me try and share this Google Doc with you guys so we can actually go in there and see. Right, there's also another document which I prepared some time ago for this thing called Tech Ladies. So we did Tech Ladies Bootcamp and we have some of our participants who are only running Windows. So this is basically the setup that we use. Basically, you first have to turn on developer mode in Windows. Then you enable the sub-systems and you set up bash on Ubuntu. So there's a few simple steps. So in any case... Right, so that's all there is to the installing Ruby. So once you have Ruby in there, so the next... Ya, I will definitely put all this information into GitHub issue as well. So I will add the link to the GitHub issue. Anyway, right, so you now have all this... Ya, I have Ruby installed on your machine. Great, there's a virtual machine. So what's next? So up next are some of the considerations when developing your application for on-premise. First up is what kind of databases are you going to use, right? So your server actually support that database that you want, say you're using Postgres, MariahDB, or SQLite. So if you really want something really simple and you're just experimenting, you might just want to install SQLite so that you can basically do this without installing additional stuff. But if you really want to really go all out, you can probably try and get Postgres usually you will have root access you can probably install all these additional things. So, because there might be implication of how much space you want to allocate and also question of whether you can run or whether your server is beefy enough to run all these things. You might even want to go with you don't even need a server at all just run everything in memory. So there will be another option. There's an API server. You want to test something or JSON. So you can basically spin up an API server using real status API and even turn off the active record. So you don't need to even bother with the database. Just deal with Ruby objects running around. Next question in my mind is how do you actually have access to the internet to do bundle install? So something to think about running things on premise already doing developing in Ruby on Rails, you want to do bundle install and you download the whole internet for all the gems that you need. Usually you will need to have access to Ruby gems website so they can actually do to get the actual packages that you need. But in cases where you don't have actual internet access on the virtual machine what you could do is use environment your development laptop. I'm sure I assume your dev laptop has at least some internet connection on the dev laptop. What you do is do a bundle install first and then you do this package called bundle package. So bundle has a way of downloading all your gems and putting them into a folder called vendor cache. So it means you basically can download all the gems that you need and put it into a cache folder and you need and then you basically check in this folder into your Git repo and when you check out the folder on the server, you just type bundle install dash dash local. So what this will do is refer to the vendor cache folder and just install the gems on your local machine rather than going to the internet and downloading it. So it's quite convenient so next the next question is do you have Node.js on the server as well because i think right now nowadays we use webpack and even the old sprockets as a compilation you need some form of java on the javascript environment so for example in some of the older Rails apps you can use Exact.js Recently I've been using something called Mini I think it's MiniRacer MiniRacer, RubyRacer So these are the few you can use to basically also run and compile your assets on the server itself but even in a situation where you really can't get javascript or Exact.js or anything on the server side what you can do is pre-compilation on your local machine public assets folder and we check in the folder and you don't need to do the asset compilation on the server side So these are some of the considerations you should take note of when developing for an on-premise environment Next thing is now you've written your app you've developed your app, you're ready to go Next question is how you deploy it so you don't have a Git server where you can do a Git pull from you can just simply zip up the folder and SCP the file onto the server or if you have Git, that is very much easier so just make your server you can just lock in there and just do a Git clone or Git pull so you just get the latest copy of the changes here there's even a more advanced way where you can set up your virtual machine as a Git server so you just push the folder in the server so there's a bit more advanced but i'll probably try and find the tutorial and share that and running your app on the server is also there's some considerations first up you can run your Rails server just by typing bundle exact Rails Rails S and what you do is oh i've left out something, bundle exact Rails server just do simple bundle exact Rails server which basically starts up your Puma server and because you want to run this in production mode you basically put in the Rails end so tell it that i'm running this in production mode bundle exact Rails server and you do a dash D to kind of make it go into daemon mode so once you run this, you basically go into the background so you don't need to have your SSH session on all the timer what nothing you want to do is also bind it to a public IP so on the server itself, you bind it to the local IP which is 127.0.0.1 but you're running this on the server side you probably want to bind it to the network port to the network card which is attached to the public so that you can actually open on your browser, on your local machine and then view the files there so as a rule you bind it to 0.0.0.0 which means you bind to any port any IP that the virtual machine has access to or if you're really kind of locked down you probably want to then bind it to a specific IP address in my case in this case i'm also pointing it to port 3000 so it's a default port so if you run some Rails server it will open up in port 3000 but you want to host this from port 80 you can do that as well you can do this in port 80 so it opens up as a default default port but then again it depends a lot a lot of this depends on what your firewall rules on your virtual machine so you probably need to check out what kind of ports are open for you from the firewall on your local server and another thing about on Linux servers if you try to host something in port 80 you need to be rude you need to be a pseudo user so suddenly take a lot of people doing this so usually i'll just go 3000 and then i can just see everything on port 3000 so basically once i run this line i should be able to see my app running on port 3000 from the URL which is given to me so if your server itself for example is running so it's an example if you're using it you have the IP address 123.2.2 for example you know the IP address you can just go straight to it or you already have a fully qualified domain which is attached to the thing like for example rails experiment for example you have something like this then you can probably use this as a way of reaching that server and of course port 3000 so this will be probably something you want to ask your ops team what have they given you or what IP address they've assigned to the server so that you can basically kit it now a few things you want to take note of when you're running this on your local on the virtual machine is that there's a couple of rails environment environment variables you want to set up when you're running in production mode you want to set up the secret key base i think a lot of us will redo stuff in hero cool we don't actually need to care about the secret key base because it's also generated for us but if you're running this on premise you probably need to be mindful of this one which is a secret key you need to set up rails will just blow up if you don't have this have this environment variable set up and also you want to turn this on in rails 5 onwards you set this environment variable your real set will then be able to serve all your static assets so do be mindful of that another thing you want to take note of is this thing called asset host so in your production.rb you probably can see this so it is helpful for setting up like cdn so for example you will testing your assets on a different server from your real server so you can actually set this up separately so these are 3 notable environment variables you want to set up maybe you might also want to use something like .m so if you use .m to kind of manage your environment variables all you need to do is to place all the in a file called .emv so once you have the .emv file it's a lot easier to manage it so otherwise you need to figure out how to actually update the batch RSE or some other thing in your server so they have all these environment variables available so it's probably not that easy and straightforward if you're not experienced in managing the servers so you can use something like this and all you need to do is save a .emv file and then you basically have access to your rails set up and you have all the environment variables that you need let me just include this link here so you can use this let me just include this link okay so let's running your rails app just simply using the railserver you can just use 4man so using 4man you can run multiple processes in 4man so you can run your railserver and your sidekick background worker and all from one command line and all you need to do is keep a file called proc file so it starts the main main process and opens up a few other processes so you can run the railserver plus your sidekick or if you're using some chronos for your scheduled jobs you can actually run all 3 process from one place okay don't start doing this or rather really no frills way of doing this is to basically first of all access into the remote server so it's a teamwork session which is a dinox multiplexing so basically we can think of it as tap browsing on the terminal so you just run teamwork and running teamwork into the shell and basically you start the process basically type 4man start in the folder and then what you do is you exit or detach from the teamwork session so you always have a terminal session running there in the background and you have 4man running as well if you're a bit more experienced managing servers, you can always use 4man and use that to export into something like upstart or systemd these are kind of like process initializers think of it as startup scripts that run when your server starts up so you can use this for example in the case of 4man you can do an export and you can export into either upstart or into i think you can also do is it here upstart so you can look at the man page you can export into systemd so we should basically it shows you how to you export some into the operating system to tell it how to start up this process as the server starts up or if you're using another version of Ubuntu you probably want something upstart for that and a few others here you can try so this is another way of running your server using 4man so these are all the examples that you roll your own you roll everything you basically install ruby you install you install ruby on your own you think about how to develop your app such that you have to roll everything on your own how to deploy it, you do everything on your own you learn how to actually start the server start the real server on your own so it's a lot of this roll your own stuff but there's also an option which can make things a bit easier which is to have a fake cloud fake cloud basically in form of cloud-like things for yourself for example, we can roll your own using docker community addition so basically install docker on the server itself and then use things like docker compose to start up your Rails app along with supporting services like Postgres, Redis and a few other things you can use docker compose to start it all up if you also want something simple, you can also use doku doku is a very nice it's a mini platform and a service so think of it as Heroku, but on premise but very small scale so you can actually run it on one single node and it's based on docker as well so basically what you do is once you have this installed you just need to do a git push to the server and you basically spin up like Heroku, you spin up an application using build packs which is a lot easier so this is another option you can use to make things a lot easier so what about Kubernetes? if you're just experimenting you ain't going to need it that's what yakni is you are not going to need it so you ain't going to need it so don't use it, please even just experimenting because you don't want to kill yourself with all the manifest configuration so if you do want to go with a fake cloud which is to have docker containers and also have some form or like supporting services that spin up together with your Rails app and I guess a lot of tutorials out there to teach you how to actually bundle or package your Rails application as a docker container so when you do that probably will be a lot easier to do all this using you can use things like docker so yeah so that's all I have for the experimental part so what about productionizing so I think we already use up 20-30 plus minutes so I think I can do the production part as a part 2 so in the future we can do another session and share a bit more about that and that's all I have any questions? okay I didn't know if you have any questions but you are a bit shy to ask you can ask in the GitHub issue or in the Ruby set channel cool okay thank you Michael for the talk okay so