Building a Django CI/CD Environment from GitHub to EC2 Using GitHub Actions (2023 Edition)

Overview I had the opportunity to build a Django CI/CD environment from GitHub to EC2 using GitHub Actions, and here are my notes. The following article was used as a reference. https://qiita.com/fffukken/items/27b0bfa712940914d3f6 I made some updates to the GitHub Actions configuration compared to the above article. GitHub Actions Configuration n o j a n o m : p p b b e u u s u : s b l b : i r s s - - - - - e h r l r l u t t n T : a _ a d n r m m e u n u w n r n r n r v S E E e n r n : s a a a p s a s i a u a u a u : E C C s c e c - t x t p s e m e t p m n p p m n p p p m n e c s & & & & & & C 2 2 t h q h o e - r y : s e s h y e : y i e : y y y e : c h s & & & & & & R _ _ e u e n g p i t : : : : t : t p : t t t : h m h E U H a s e s : y a x h h | h | h h h o c g p p d s T S O n : s : : r : o a S a o I o i R o o o d d d i y y e u _ E S d t u a n c e c n n n n u n n n e " o t t t a d K R T [ : [ b l - t t t - s s n p $ 6 S ~ h h c o E : : D u l v i i v t - t m m m l S 0 t / p o o t Y e d d n e e o u o e a m a T a a a o E 0 r < u n n i s : $ $ p e e t l r n p n r l l e n n n y C i プ l v y { { l v v u : s s s s l p l s a a a R s c ロ l m m a s $ { { o e e - i / P / i i t g g g E e t ジ a a t t { y l l l 4 o c y s o D p - s e e e T c H ェ o n n e e { s s o o a n h t e n e r . . . _ r o ク r a a m e e p p t : e h t : p i p p p K e s ト i g g \ c s c c , e c o u e n r y y y E t t 名 g e e t e r r ] s [ k n p $ n s e Y _ K > i . . l c e e m t 3 o - { d t q m m t " k e \ n p p r t t a . u $ p { e a u a i e e y y y r e s s i 9 t { y n l i k g s > y C m e t . . n , @ { t m c l r e r t h a m m s s E E v h a i e m a s e i a i t . C C ] " 3 m o t e m i t e c n k g a S 2 2 3 a n r s - e g e c k e r r E _ _ . t @ i u n r r i \ m a t C U H 1 r v x p t a e n i t R S O 0 i 4 . g s t t g g e g E E S " x p r . i _ = r u T R T ] . y a t o k n a \ n _ p t d x n e o t i K } } y h e t s y i c E } } t o $ o o Y h n p { n r o - i E s n } n v p C " } - e 2 \ v r _ e s U r i S s o E i n R o } n } @ } $ } { } E C 2 _ H O S T } - i s e c r e t _ k e y " s o u r c e < 仮 想 環 境 名 > / b i n / a c t i v a t e \ The changes made were updating the versions of actions/checkout and actions/setup-python. I also changed the pip install section to pip install -r requirements.txt. ...

July 9, 2023 · 5 min · Nakamura

Bulk Deleting Amazon ECR Repositories

Overview I had an opportunity to bulk delete Amazon ECR repositories, so here are my notes. Please exercise caution when running these commands. Creating a List of Repositories I referenced the following article. https://qiita.com/fk_2000/items/bffd3b1ad6f3ab109766 Run the following command. a w s e c r d e s c r i b e - r e p o s i t o r i e s o u t p u t j s o n | j q - r e " . r e p o s i t o r i e s [ ] . r e p o s i t o r y N a m e " > r e p o s i t o r y . l i s t On macOS, if you don’t have the jq command, install it with brew install jq. ...

June 6, 2023 · 2 min · Nakamura

Creating a REST API Using OpenAPI and AWS CDK (OpenSearch Connection and Custom Domain)

Overview I had the opportunity to create a REST API using OpenAPI and AWS CDK, so this is a memo. The following article was very helpful. https://zenn.dev/taroman_zenn/articles/91879cec40627c The project created this time is published in the following repository. https://github.com/nakamura196/CdkOpenapi Connecting to OpenSearch The implementation is done in the following Lambda. https://github.com/nakamura196/CdkOpenapi/blob/main/lambda/search.ts Environment variables need to be passed to the Lambda, and the following was written in the ts file under lib. ...

May 26, 2023 · 3 min · Nakamura

Integrating Strapi with Amazon OpenSearch

Overview The following article was helpful for integrating Strapi with Elasticsearch. https://punits.dev/blog/integrating-elasticsearch-with-strapi/ The source code is also publicly available. https://github.com/geeky-biz/strapi-integrate-elasticsearch Here, I will note some customizations made based on the above article, including integration with Amazon OpenSearch. The customized source code is available here: https://github.com/nakamura196/strapi-integrate-opensearch Modifications The article references indexing_type, but it needed to be changed to indexing_request_type. https://github.com/nakamura196/strapi-integrate-opensearch/blob/006c533d4d7882fc9779552db31a7b0e2ada5e57/elastic/cron-search-indexing.js#L16 Additionally, to use Amazon OpenSearch instead of Elasticsearch, the following libraries need to be installed. ...

May 26, 2023 · 2 min · Nakamura

AWS CDK x CloudFront x S3 x Basic Auth x index.html Support x Custom Domain

Overview I used AWS CDK to create a static site with CloudFront + S3. Additionally, I used CloudFront Functions to add Basic authentication and processing to append index.html to requests that do not include a filename or extension in the URL. I also added a custom domain, so this is a memo of the process. While somewhat incomplete, the source code is available in the following repository. https://github.com/nakamura196/staticBasic The intended use is to prepare an .env file like the following and run cdk deploy. ...

May 16, 2023 · 14 min · Nakamura

Connecting Drupal with Amazon OpenSearch Service

Overview I had the opportunity to connect Drupal with Amazon OpenSearch Service, so this is a personal note for future reference. The following article was helpful. https://www.acquia.com/jp/blog/intergration-with-drupal-and-elasticsearch Module Installation In addition to drupal/search_api and drupal/elasticsearch_connector, it was necessary to install nodespark/des-connector. (There may be room for improvement in how version specifications are handled.) c c c o o o m m m p p p o o o s s s e e e r r r r r r e e e q q q u u u i i i r r r e e e " ' " n d d o r r d u u e p p s a a p l l a / / r s e k e l / a a d r s e c t s h i - _ c c a s o p e n i a n : r e ^ c c 1 h t . _ o 2 c r 9 o : ' n ^ n 7 e . c x t - o d r e v ^ " 7 . 0 @ a l p h a " Then, enable them with the following. ...

April 13, 2023 · 5 min · Nakamura

Running Strapi on Amazon Lightsail (SSL, Custom Domain)

Overview I had the opportunity to run Strapi on Amazon Lightsail, so this is a personal note. I referenced the following article. https://zenn.dev/holykzm/articles/1e54cc25207657 Instance Select Node.js. Please select one with 1GB or more of memory. If you build on Lightsail, an out-of-memory error will occur. SSL, Custom Domain Please refer to the following. /en/posts/5772d6c918508a/#独自ドメインの付与 Assign a Static IP, set up a custom domain with Route 53, and execute the following. ...

April 11, 2023 · 4 min · Nakamura

Web Application for NDL Classical Book OCR Using Hugging Face Space

Overview I created a web application for NDL Classical Book OCR using Hugging Face Space. You can try it at the link below. Upload an image, and after about 1 minute, the OCR result text and JSON data will be displayed. https://huggingface.co/spaces/nakamura196/ndl_kotenseki_ocr The following article was used as a reference for creating this application. https://qiita.com/relu/items/e882e23a9bd07243211b Choosing the Right Tool I have separately prepared a Google Colab tutorial as another environment for trying NDL Classical Book OCR. ...

March 27, 2023 · 2 min · Nakamura

Running NDL Classical Japanese OCR on Amazon EC2 CPU Environment

Overview This is a memo of running NDL Classical Japanese OCR on an Amazon EC2 CPU environment. The advantage is that it can be run without preparing an expensive GPU environment, but please note that it takes about 30 seconds to 1 minute per image. The following article was referenced when building this environment. https://qiita.com/relu/items/e882e23a9bd07243211b Instance Select Ubuntu from Quick Start. For the instance type, I recommend t2.medium or higher. Errors occurred with smaller instances. ...

March 27, 2023 · 11 min · Nakamura

Running NDL Classical Text OCR Using Amazon SageMaker Studio

Overview Previously, I created tutorials for NDL OCR and NDL Classical Text OCR using Google Cloud Platform and Google Colab. This time, I will explain how to run NDL Classical Text OCR using Amazon SageMaker Studio. Please note that this method incurs costs during execution. The description of Amazon SageMaker Studio is available at the following link: https://aws.amazon.com/jp/sagemaker/studio/ Domain Setup and Other Configuration For domain setup and other configuration, please refer to articles such as the following: ...

February 27, 2023 · 2 min · Nakamura

Setting Up Archivematica on Amazon EC2

Overview Archivematica is open-source software for long-term preservation of digital data. https://www.archivematica.org/en/ I had the opportunity to set up Archivematica on Amazon EC2, so this is a memo. Installation The installation instructions are described on the following page. https://www.archivematica.org/en/docs/archivematica-1.13/admin-manual/installation-setup/installation/installation/ There are several options, but this time I tried “CentOS 7 64-bit, Installing Archivematica on CentOS/Red Hat.” https://www.archivematica.org/en/docs/archivematica-1.13/admin-manual/installation-setup/installation/install-centos/#install-pkg-centos EC2 Instance Since CentOS 7 was specified, I selected the following Amazon Machine Image (AMI). ...

February 8, 2023 · 19 min · Nakamura

Script for Initial Setup of Omeka S on Amazon Lightsail (Adding the Easy Admin Module)

I created an updated version of the “Script for Initial Setup of Omeka S on Amazon Lightsail” introduced in the following article. This version adds “Easy Admin,” which makes it easy to add themes and modules, and also fixes permissions for related directories. I hope you find this helpful. # O # D V # s m # w u m # m # r r # i f # c [ u p h E m # c u p d h E s s # c # w u r s s s M # B E # e k g n v v m m f i a c s a o O y a s a b o O u u d # g n m u u u 変 E N R # t d O e z . 不 元 r デ t l e s s F s O t e s n s F d d M e z d d d 数 K ハ A S # i m t i o h o 要 - o か [ m ー i r s t q m r s a t o o o $ e t i E o o o A イ M I # - r e p m t m な r m ら タ e w l e w m d O a p a _ フ E O # e k h e a e フ f e あ - $ ベ < n = o = k < = o e = c a u M s h s c c c P ン = N # $ a t - k c k ォ k っ e O ー E t r a E r h p l E y t E y h h h A は o = # O の t q a c a ル o a た M ス O ] r d l - O r d = l o t e K t a A o o o T 含 m 3 # M ダ p - e - ダ m - i $ E の F o o d S F o o w A a p s d w w w H め e . # E ウ s o s s s の e s n O K 作 o = c e の o = $ c n i _ d s y m n n n = な k 2 # K ン : m / s / 削 k - d M A 成 > t a f 設 > t D a n P m : A i / い a . # A ロ / e * の . 除 a $ e E _ $ l a 定 $ B l - s A i / d n - - - h _ 3 # _ ー / k 移 h - V x K P s ( h u $ ( N h R t T n / m - R R R o s P ド g a $ 動 t s E . A A q c o l O c A o a H g i 3 m A i - O a R h _ T l a s t M a M s d l / i n . d d d e T t s M c S t P H . t t s E t E t a l m t - 3 a a a / H h - E c I m A / c - K e o h 3 . e e e b u $ K e O l T i n / e A b m i d u . 7 m m m i b V A s N を H n f h x _ i o m u b 3 . o o o t . E _ s . 削 / d o t P t n a l . . z n n n n c R P z 除 i e m r A n : g e c 7 i : : : a o S A $ i ( n x e a T a d e s o . p d d d m m I T O p も d . / - H m a m m z a a a i / O H M し e h b f / i e a / i e e e / o N E 存 x t i i c _ m g D p m m m h m . K 在 . m t l o a o i a o o o t e z A す h l n e n p n c n n n n d k i _ れ t a = f p k i o a p P ば m m s i l $ e $ $ $ c / A ) l i q g i O - l O O O s o T / l / c M y - M M M / m H ] b . d a E K E E E o e ; i c a t K M K K K m k t n t i A / A A A e a t n f a o _ O _ _ _ k - h a b n P m P P P a s e m - a _ A e A A A - / n i e s p T k T T T s r _ e a H a H H H e a " . s / - / / / l p c i s f S f m t e p r n w i - i o h a l e i o l m l d e s i a r e o e u m e c t d s d s l e s a e ) u e s / t l s d i d e o o a - w n t E n _ a a l p b s o a a y a s s A d s e d / w m v o $ i $ r D n V d B / E ) N r R A e S M l I E e O " a N ; s / e o s m / e d k o a w - n s l - o $ a V d E / R 3 S . I 3 O . N 7 . / z E i a p s y A d m i n - 3 . 3 . 7 . z i p

December 24, 2022 · 6 min · Nakamura

Deploying Nuxt 3 on Amazon Lightsail: Using pm2

Introduction When deploying applications developed with Nuxt 3 and similar frameworks, I often use GitHub Pages, Netlify, AWS Amplify, and Serverless Framework + Lambda. However, this time I had the opportunity to deploy using a VPS, so this is a memo. References Specifically, I use Amazon Lightsail and pm2. Creating an Amazon Lightsail Instance Select the Node.js blueprint. Also, since port 3000 is used, open the firewall for it. ...

December 22, 2022 · 4 min · Nakamura

TODO Memo for EC2 Server Setup

This is a TODO memo for setting up a server on EC2. Assign an Elastic IP Add a User with sudo Privileges s u p u u s a s d e s e o r s r a w m s d d o u d d n n a - a k G k a a m w m u h u r e r a e a l n a k a m u r a Set Up Public Key c m t c c v c d k o h h i h d u m m o / i c o o . w h r h d d s n o s m . . 7 6 h - e s s 0 0 / R / s s 0 0 a n h h u n a / . . t a k a s s h k a u s s o a m t h h r m u h / i u r o a z r a r u e a i t d : z h _ n e o k a d r e k _ i y a k z s m e e u y d r s _ a k e . y s s s h

December 5, 2022 · 2 min · Nakamura

Script for Initial Setup of Omeka Classic on Amazon Lightsail

I created a script for the initial setup of Omeka Classic on Amazon Lightsail. This is the “Omeka Classic version” of the following article. I hope this serves as a helpful reference when using Omeka Classic with Amazon Lightsail. # O # D V # s m # w u m # m # r r # i f # c [ u p h E m # c [ h u p d p c E s s M # B E # e k g n v v m m f i a c s a o O y a d o s a b r h O u u V E N R # t d D e z M R R r C t l e s s F s O t a s e s n e a F d d a K D A S # i o t i o o o e - o e [ m r i r s t q m t t r s a f r o o r A o M I # - r w p m v m m r m m e e w l e a n w m i s i _ E O # e n h e e e o f e o - $ a < n = o = k < b a o e x e c a a P n = N # - l t - k k v k v e O t E t r a E a m r t h p b A o o = # p o t q a . a e o a e M e O ] r d l - O s e d o t l T t m 3 # a p - h - m - $ E F o o d S F e w e H e . # $ d s o $ t $ u e $ e O K d o = c e ] = = = = = = n i s = i k 0 # O : m V a V n k V x M A a > t a f c > n / n a . # M O / e E c E n a E i E _ t $ l a o l r $ $ " " - s h c 3 # E m / k R c R e - R s K P a s ( h u n $ o o ( D o u R t o l K e g a S e S c $ S t A A b q c o l f O c o c B m t a m u A k i - I s I e V I i _ T a l a s t i M a t a N e f d l e d _ a t $ O s O s E O n P H s . t t s g E l t A k 8 a l / e P h V N N s R N g A / e c - u K h M a " e b A u E / / a S . T i n / e r A o b E _ m i i h T b R * . r I z i H n f h x a _ s i " o m t y H . S h y O i n / d o t t P t t n a n p c I $ t N p d i e m r i A n : g a h o O O a f e n x e a o T a d e m e m N M c o x d . / - n H m a m i n / . E c l . e h b f / i e a / s o z K e d h x t i i d _ m g h m i A s e t . m t l b a o i t e p _ s r m h l n e . p n c d k P s l t a = i p k o a A $ m m s n l $ c / T O ( l i q i i O - s O H M i / l c M y / m E f ] b . a E o e K ; i c t K m k A i t n i A e a _ t t n f o _ k / P h a n P a r A e e m - _ A e T x n i e p T l H i _ a H e s a " s / a t p c s f s s p r w i e ) l e o l s i a r e / c t d s d a e ) o t w i d n o a l n t o _ a a p b d a a / s s v s e $ w V o $ E r D R d B S ) N I A O M N E / " o ; m e k a - $ V E R S I O N . z i p

October 13, 2022 · 5 min · Nakamura

An Example of Deploying Nuxt 3 to Netlify and AWS

Overview This is a personal note on an example of deploying Nuxt 3 to Netlify and AWS. Below are the deployment examples. Netlify app.vue https://nuxt3-nakamura196.netlify.app/ server/api/hello.ts https://nuxt3-nakamura196.netlify.app/api/hello AWS (Serverless) app.vue https://nuxt3.aws.ldas.jp/ server/api/hello.ts https://nuxt3.aws.ldas.jp/api/hello The source code is at the following URL. https://github.com/nakamura196/nuxt3 I will explain each of them below. Netlify By referring to the following article, I was able to deploy including BFF (Backend for Frontend). https://blog.cloud-acct.com/posts/nuxt3-netlify-deploy/ AWS (Serverless) The following article was helpful for the method using Lambda Functions URL. ...

October 11, 2022 · 2 min · Nakamura

Script for Initial Setup of Omeka S on Amazon Lightsail

I created a script for the initial setup of Omeka S on Amazon Lightsail. I hope this serves as a useful reference when using Omeka S with Amazon Lightsail. # O # D V # s m # w u m # m # r r # i f # c [ u p h E m # c u p d h E s s M # B E # e k g n v v m m f i a c s a o O y a s a b o O u u 変 E N R # t d O e z . 不 元 r デ t l e s s F s O t e s n s F d d 数 K ハ A S # i m t i o h o 要 - o か [ m ー i r s t q m r s a t o o A イ M I # - r e p m t m な r m ら タ e w l e w m _ フ E O # e k h e a e フ f e あ - $ ベ < n = o = k < = o e = c a P ン = N # $ a t - k c k ォ k っ e O ー E t r a E r h p A は o = # O の t q a c a ル o a た M ス O ] r d l - O r d = l o t T 含 m 3 # M ダ p - e - ダ m - i $ E の F o o d S F o o w H め e . # E ウ s o s s s の e s n O K 作 o = c e の o = $ c n i = な k 2 # K ン : m / s / 削 k - d M A 成 > t a f 設 > t D a n / い a . # A ロ / e * の . 除 a $ e E _ $ l a 定 $ B l - s h _ 3 # _ ー / k 移 h - V x K P s ( h u $ ( N h R t o s P ド g a $ 動 t s E . A A q c o l O c A o a m A i - O a R h _ T l a s t M a M s d l e T t s M c S t P H . t t s E t E t a l / H h - E c I m A / c - K e b u $ K e O l T i n / e A b m i i b V A s N を H n f h x _ i o m t . E _ s . 削 / d o t P t n a n c R P z 除 i e m r A n : g a o S A $ i ( n x e a T a d e m m I T O p も d . / - H m a m i / O H M し e h b f / i e a / o N E 存 x t i i c _ m g h m . K 在 . m t l o a o i t e z A す h l n e n p n c d k i _ れ t a = f p k o a p P ば m m s i l $ c / A ) l i q g i O - s o T / l / c M y / m H ] b . d a E o e ; i c a t K m k t n t i A e a t n f a o _ k - h a b n P a s e m - a _ A - / n i e s p T s r _ e a H e a " . s / l p c i s f e p r n w i a l e i o l s i a r e e c t d s s a e ) / t d i d o o a w n t n _ a l p b o a a a s s d s e / w v o $ $ r D V d B E ) N R A S M I E O " N ; / o m e k a - s - $ V E R S I O N . z i p

September 9, 2022 · 4 min · Nakamura

Building a Virtuoso RDF Store Using AWS EC2

Introduction These are notes on building a Virtuoso RDF store using AWS EC2. This covers custom domain configuration, HTTPS connection, and Snorql installation. There are many other useful articles on building Virtuoso. Please refer to them as well: https://midoriit.com/2014/04/rdfストア環境構築virtuoso編1.html https://qiita.com/mirkohm/items/30991fec120541888acd https://zenn.dev/ningensei848/articles/virtuoso_on_gcp_faster_with_cos Prerequisites An ACM Certificate should already be created. Please refer to articles such as the following: https://dev.classmethod.jp/articles/specification-elb-setting/#toc-3 EC2 First, create an EC2 instance. Select Amazon Linux, and set the instance type to t2.micro. ...

August 16, 2022 · 8 min · Nakamura

Hosting Hugging Face Models on AWS Lambda for Serverless Inference

Overview This is a personal note on hosting Hugging Face models on AWS Lambda for serverless inference, based on the following article. https://aws.amazon.com/jp/blogs/compute/hosting-hugging-face-models-on-aws-lambda/ Additionally, I cover providing an API using Lambda function URLs and CloudFront. Hosting Hugging Face Models on AWS Lambda Preparation For this section, I referred to the document introduced at the beginning. https://aws.amazon.com/jp/blogs/compute/hosting-hugging-face-models-on-aws-lambda/ First, run the following commands. I created a virtual environment called venv, but this is not strictly required. ...

July 17, 2022 · 8 min · Nakamura

Scheduled Backup of Omeka S Data Using AWS Copilot

Overview I previously created a program to download Omeka S data. This time, I use AWS Copilot to run the above program on a scheduled basis. Installing AWS Copilot Please refer to the following. https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/developerguide/AWS_Copilot.html Preparing Files Create three files in any location: Dockerfile, main.sh, and .env. Dockerfile F C C R O M O P D M Y s p h y . t s m h h a o i n . n : . 3 s h main.sh s e # e d d # i f # g g # c p p # c s # o m c c c # g g g g g g # c r r e x x i i f i i i d i i d h d k d p p i i i i i i d m m t p P p r r I r r c t t r p p E c i d g t t t t t t C o r o _ _ f [ m m l e $ x s m o r i $ - - i l - - - r o r t d o c c q d i i e r a p = r o r r t s a c c c p e r r e t g t o a f - - - n l l u i n n c c i y . d t d o o o u a f f r o t o d r r e o o i r s s u n . - i a d n n m s n o a r l a l f f n n r _ t t t . / p r t f f m h u $ $ u m e = s d $ e e e t a a e s . u . i i i p d d t p t e e d $ $ m o l l h . $ s g g t i i p t o o t r i d d e o l l / o r r u o _ o = r i i - - n l $ d / u u - _ _ t t l d e _ r r d d t - d i $ $ s s m t d _ d o a x t _ _ e e s - r i r d d e e o a d o o t i o t d p p . u r i i r r " o t i w l a s o o a t t t p r _ r r . . u l a r n = s t l o t h h x g e d _ _ e n p s = l h e s l a t r q a t t m a d e . o t t ] s 1 1 a u t o o a m a t . a t ; e d i a o o i e t / d p t $ $ e r s l l l e d s t r r e e / / " " o d : h e e p m t d d " $ c a / e p p i e / a o $ n s t / n o o p n $ t c e a a g _ _ t s a s m m i t d s u a e f t o a . b . . i " r h o t t d l o u l a x i " m b s t r . $ e O c d t m o i e m r $ k / _ d a n t i a o r S k o _ a l d m a u t r a a s 1 e 9 t 6 / o m e k a s _ b a c k u p . g i t .env a g u e d p i s m i i t e a r _ h r i n u u n l a r b a = m l _ m n e = u e a = h r = k d t l n a e t = a m v p h k u s t a r : t m a / p u @ / s r e d : a x e / a m < p o p l m e e e r . k s o a o r . n g o a r l g - / a o c m c e e k s a s - - s t - o s k a e n n d > b @ o g x i / t a h p u i b . c o m / < u s e r n a m e > / < r e p o s i t o r y - n a m e > . g i t The following is an explanation of the parameters. ...

June 24, 2022 · 12 min · Nakamura